package server1; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.SourceDataLine; import java.net.*; import java.io.*; public class Kuulaja { /** * @param args */ public static void main(String[] args) throws Exception{ AudioFormat formaat=new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 8000, 8, 1, 1, 8000, true); SourceDataLine line = (SourceDataLine) AudioSystem.getLine( new DataLine.Info(SourceDataLine.class, formaat, AudioSystem.NOT_SPECIFIED) ); line.open(formaat); line.start(); Socket sc=new Socket("localhost", 3001); InputStream is=sc.getInputStream(); byte[] andmed=new byte[24000]; while(true){ is.read(andmed); line.write(andmed, 0, andmed.length); } //Pange server greenysse //Pinginaabriga ühe arvutisse kuulaja, teise arvutisse //saatja ja proovige serveri kaudu teise juttu kuulata. } }