[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

streams

Posted on 2001-06-28
23
Medium Priority
?
403 Views
Last Modified: 2010-08-05
How can i pass the streams from one program to another program
0
Comment
Question by:anmadhu
  • 6
  • 6
  • 5
  • +5
23 Comments
 
LVL 3

Expert Comment

by:rjackman
ID: 6237065
hi
u can pass the stream object like a param to method for e.g
if i have 2 classes class1 and class2
in class1 i am using stream object and i ma passing it to class2 which is another prog as parameters

import java.io.*;

public class1
{
  private BufferedReader reader;
  public class1()
{
  reader = new BufferedReader(new FileReader(new File("path of the file")));
  //call other class and pass this to other class
   new class2(reader);
 
}


}

cheers
RJackman
public class2
{
  private BufferedReader reader;
public class2(Reader reader)
{
  this.reader=reader;
}
}
0
 

Expert Comment

by:rameshnut
ID: 6237264
Hi anmadhu

Can you please be more specific when you say from "program" to "program".
if i am not mistaken,did you mean from one class to another class or from one function to an other?? Is it so?
Please be clear


 
0
 
LVL 1

Expert Comment

by:gtloafer
ID: 6237319
Within the same application you should be able pass a reference no problem. But now if you are thinking of say serializing the object ? Well thats a different story altogether - i.e. no can do.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:gtloafer
ID: 6237322
Sorry I dont think I was clear there ...when I said object I meant the stream object
0
 
LVL 2

Expert Comment

by:jorj
ID: 6237500
Do a pipe. Use Server/client and TCP connection on the same computer. You will get egt streams which only had to be connected using pipe mechanism.
0
 

Author Comment

by:anmadhu
ID: 6237823
No still there is problem.  If i speak in the mic i shold hear the voice in the speaker.The speaking in mic shold convert into a bytes in one program , and the hearing the sound in speakers is in another program .
How can do it? Can u catch my point?EXPERTS please clarify my problem?
0
 
LVL 2

Expert Comment

by:jorj
ID: 6237913
Java ? You cannot do this. C++ ? Maybe, with some hacking.
So the answer is no or very hard in Java. You must somehow to do a program which catch the incomming stream and redirect it.

I'm affraid your problem hasn't a pleasant solution for you.
0
 

Author Comment

by:anmadhu
ID: 6238058
Mr Ori Why can't do in JAVA. and

How Can i don in C++?Please Can u explain?
Thanking you for your better co-operation
0
 
LVL 2

Expert Comment

by:jorj
ID: 6238121
Java provide weak support for accessing physical resources on host machines, so C is a solution for you.
But, in order to accesss low-level resources as you'll have to do, you need to write a special kind of driver if you're using Windows systems.
So the easyer solution for you will be do to such things from DOS where you can get access to any resources you want. I don't think this is what do you want.
 
another thing is how to access the incomming stream. You will have to do the entire software regarding the audio-board programming.

If you still want to do this you'll need many programming knowledges and ask for this at the C experts.

0
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6239645
Well, bit late in the Thread!

What I can understand is, your Program 1 is responsible for converting voice to bytes and Program 2 will receive them to do further processing.

It can be acheived through Java Sockets. Visualize the programs in a Client/Server mechanism.

As a connection is established, each of the Socket is associated with I/O Streams. Data can be read from and written to them.

0
 
LVL 1

Expert Comment

by:viswa081400
ID: 6239681
Yeah!
You can achieve it using sockets and JMF which has an API for audio and vedio devices. That should be real helpful for this.

Visit this link on JMF
http://java.sun.com/products/java-media/jmf/index.html

so that should be possible.

good luck
0
 
LVL 2

Expert Comment

by:jorj
ID: 6240941
I think the other experts missunderstood the point: anmadhu has two written programs and want to link the streams together, NOT writing the programs again. In this case Java wouldn't help him and with C has small chances. Please correct me if I'm wrong.
0
 

Author Comment

by:anmadhu
ID: 6247955
Mr Sghosh,  your correct Sir.
How can i do it? could  u please explain me with some simple program.
Thanking u
madhu
0
 
LVL 2

Expert Comment

by:jorj
ID: 6248095
anmadhu,
please be more specific with your needs: what do you have and what are do you intend to do. Linking streams is one thing (means you have two programs and you want them to communicate), programming for handling audio sources and manipulating them is another.
0
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6250290
If you choose to pass the data via sockets, you need to do the following:

Program 1 (Receiver): Processing of bytes
It will open a Server Socket at a certain port and wait for the bytes from program that does the voice to bytes conversion.

ServerSocket serverSocket = new ServerSocket(9000);
InputStream in = serverSocket.getInputStream();
OutputStream out = serverSocket.getOutputStream();

while (true)
{
// Bytes have arrived
if (serverSocket.accept())
{
  // Read the Bytes and do processing
  byte[] b = new byte[1000];
  in.read(b);
  // The bytes are available in byte array b
}

}
Program 2(Transmitter): Conversion of voice to bytes
It will establish connection with the Receiver program through Socket too.

Socket socket = new Socket("156.65.124.39", 9000);
// 156.65.124.39 denotes the host of Server Program
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();

// Conversion of voice to bytes
// in byte[] b
// Write to the Stream
out.write(b);
out.flush();

You can try the code with a small chunk of byte array and see how it works. Once you have made your client and server programs to communicate, you can work on the voice to byte array conversion which can be achieved by Java Media API.

Good luck!

0
 

Author Comment

by:anmadhu
ID: 6252374
Hello
This is madhusudhanan .Can u give me your  personnal mail id  I want to discuss with this things
Thanking you for your best cooperation
Bye
madhu
0
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6253821
Who is the addresse?
0
 

Author Comment

by:anmadhu
ID: 6254438
Mr Sqhosh,
I used your code in my program. I got the compilation error.That is, the first line is working perfectly.
1. ServerSocket serverSocket = new ServerSocket(9000);
 
 In the second line i got the compilation error that is,there is no method getInputStream().
2.InputStream in = serverSocket.getInputStream();
Could you correct this one.
Thanking you for your best co-operation
bye
madhu



0
 
LVL 2

Expert Comment

by:jorj
ID: 6255465
:) First, I don't want to be bad.
But,
anmadhu, (and others) what do you think you'll split the points when a general problem like yours need so many replys ? You want to connect streams, do the two applications you'll need to connect but you got blocked in the second line of a program and ask elementary questions, which are also very poor in details (as is the problem itself). Would you do something ? Explain your needs in detail, we'll give you the source code or links so you'll only need to compile them.
Sorry, but I am bored of this thread. Try to read more and ask less if you'll ever want to do something.
0
 
LVL 3

Accepted Solution

by:
sghosh092199 earned 1200 total points
ID: 6256636
anmadhu,

Incorporate the following changes:

ServerSocket serverSocket = new ServerSocket(9000);
while (true)
{
// Bytes have arrived. The accept() blocks itself till
// no connection is made
Socket socket = serverSocket.accept();
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();
// Read the Bytes and do processing
 byte[] b = new byte[1000];
 in.read(b);
 // The bytes are available in byte array b
}



0
 

Author Comment

by:anmadhu
ID: 6258869
Mr Sqhosh, May i get your personal mail id.
My mail id: anmadhu@yahoo.com
May i get your mail id?
Thanking u for your Best Cooperation
madhu
0
 
LVL 3

Expert Comment

by:sghosh092199
ID: 6259534
You can reach me at sghosh@entigo.com
0
 

Expert Comment

by:CleanupPing
ID: 9062013
anmadhu:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month19 days, 8 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question