How do I play a wave file sent from server?
<p>I send a wave file using a client and server method.</p>

<p>How could I play this file on the client once it's received?</p>

<p>This is the server code used to send the wave file:</p>

<pre><code>import java.lang.*;
import java.io.*;
import java.net.*;

class Server {
//D:\Documents and Settings\Desktop\gradpro\test1
    static final String OUTPUTFILENAME = "C:\\Documents and Settings\\Administratore\\Desktop\\gradpro\\test1\\s1.wav";
    static final int PORT    = 8811;

    public static void main(String args[]) {

        System.out.println("New server running...\n\n");

        // Infinite loop, innit
        while ( true ) {

            try {
                //Create a socket
                ServerSocket srvr = new ServerSocket(PORT);
                Socket skt = srvr.accept();

                //Create a file output stream, and a buffered input stream
                FileOutputStream fos = new FileOutputStream(OUTPUTFILENAME);
                BufferedOutputStream out = new BufferedOutputStream(fos);
                BufferedInputStream in = new BufferedInputStream( skt.getInputStream() );

                //Read, and write the file to the socket
                int i;
                while ((i = in.read()) != -1) {
                    out.write(i);
                    //System.out.println(i);
                    System.out.println("Receiving data...");
                }
                out.flush();
                in.close();
                out.close();
                skt.close();
                srvr.close();
                System.out.println("Transfer complete.");
            }
            catch(Exception e) {

                System.out.print("Error! It didn't work! " + e + "\n");
            }

            //Sleep...
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ie) {
                System.err.println("Interrupted");
            }

        } //end infinite while loop
    }



}
</code></pre>
