ByteArrayOutputStream & Socket

Hi, I have a thread which will perform sound capturing. The output will be stored in a byteArrayOutputStream. Now, i want to send the byteArrayOutputStream to server, and the server will read it then send the byteArrayOutputStream to all clients..I have no idea what jave.io classes should i use? should I use BufferedInputStream and BufferedOutputStream? or others? I tried to understand all the classes and methods but kinda hard to understand..

hope someone can help, thanks..your help is really appreciated.

[524 byte] By [brennan7a] at [2007-10-2 16:29:44]
# 1

My codes look like this:

class CaptureThread extends Thread

{

byte tempBuffer[] = new byte[10000];

public void run()

{

try

{

bw = new BufferedOutputStream (soundSocket.getOutputStream());

}

catch (Exception mn)

{

System.out.println(mn);

}

stopCapture = false;

try

{

while(!stopCapture)

{

int cnt = targetDataLine.read(tempBuffer,0,tempBuffer.length);

if(cnt > 0)

{

byteArrayOutpurStream.write (tempBuffer,0,cnt)

}

}

}

catch (Exception e)

{

System.out.println(e);

System.exit(0);

}

}

}

FOR SERVER SIDE:

Socket soundSockets;

BufferedInputStream bis;

BufferedOutputStream bos = new BufferedOutputStream(soundSockets.getOutputStream());

while(true)

{

for(int i=0;i<socketvector.size();i++)

{

soundSockets=(Socket)socketvector.elementAt(i);

bis=new BufferedInputStream(soundSockets.getInputStream());

if(bis.available()>0)

{

audio=bis.read();

try

{

bos.write(input);

bos.flush();

}

catch (Exception msg)

{

System.out.println (msg);

}

}

}

}

brennan7a at 2007-7-13 17:31:42 > top of Java-index,Java Essentials,Java Programming...