java sound與socket問題!

lovexanadu發表於2002-12-27
我想做一個語音聊天程式,從Microphone輸入獲取音訊資料流,然後透過
socket套接字傳輸,但是在客戶端接受到輸入資料流後進行音訊資料流的轉化出現了異常,不知如何解決,請高手賜教!附上部分原始碼:

伺服器端:
BufferedOutputStream bos=new BufferedOutputStream(socket.getOutputStream());
while(thread != null){
if((numBytesRead= line.read(data, 0, bufferLengthInBytes)) != -1){
bos.write(data, 0, numBytesRead);
}else{
break;
}

客戶端:
Socket socket=new Socket("xanadu",7890);
InputStream is=socket.getInputStream();
//就在下面這一部出現了異常
AudioInputStream audioInputStream
=AudioSystem.getAudioInputStream(is);
異常顯示:java.io.IOException:mark/reset not supported

請問應該如何解決?或者還有其他的方法可以將套接字流轉化為音訊流?

相關文章