Inputstream.available() always returns 0
<p>I got some stupid problem, I don't know what am i doing wrong.</p>

<p>I wrote client and server, client is working properly.  I checked that output stream works properly in client there are bytes, but in server when a client connected, method in.avaible() returns always zero? Why?</p>

<p>SOme code of my server: </p>

<pre><code>            try{
            serverSocket = new ServerSocket(port);
        }
        catch (IOException e){
            System.err.println("Could not listen on port: " + port);
            return false;
        }
        System.out.println("Server Started");
        txtServer.setText("Server wystartował");
        return true;
        }
        else{
        txtPort.setText("Brak Portu!");
        txtPort.setBorder( BorderFactory.createLineBorder(Color.RED) );
        return false;}
    }

    @Override
    public void run() { 
        try{
            clientSocket = serverSocket.accept();
            data.clear();

            System.out.println("Client connected");
            cl_obs = new Client_obs(clientSocket, data);
            Thread t = new Thread(cl_obs);
            t.start();
        }
        catch (IOException e){
            System.err.println("Accept failed.");
            System.exit(1);
        }           


    }
          package Server;
          import java.io.IOException;
          import java.io.InputStream;
          import java.net.Socket;

          public class Client_obs implements Runnable {
      private InputStream in;
      private data data;
      private Socket clientSocket = null;
      public Client_obs(Socket cl, data data1){
        clientSocket =cl;
        data = data1;
    }
    @Override
    public void run() {
        try {
            in = clientSocket.getInputStream();
            byte[] data1 = new byte[in.available()];;           
            for (int i=0; i&lt;data1.length; i++){
            data1[i] = (byte)in.read();
            }
            data.setData(data1);
            data.displayMSG(data.getdata());
            in.close();
            clientSocket.close();

        }
        catch(IOException e){
            e.printStackTrace();
        }
    }

}
</code></pre>
