title: Multiple Input/Output streams in Java?
body: <p>I ran into a problem while using input/output streams in Java. My thought was to have a <code>DataInputStream</code> to handle receiving text and a <code>PrintStream</code> to pass messages to the server from the server and object(output/input)streams to handle passing piece movements and current board image.</p>
  
  <p>My problem is that the code hangs while it is trying to create the <code>ObjectInputStream</code> in the code below. Is this because I am trying to have multiple input and output streams? If so is there any possible fix I could use?</p>
  
  <pre><code>       Socket sock = new Socket("127.0.0.1", 1716);
         input = new DataInputStream(sock.getInputStream());
         printer = new PrintStream(sock.getOutputStream());
  
         System.out.println("Test 1");
         zelda = new ObjectInputStream(sock.getInputStream());
         System.out.println("Test 2");
         link = new ObjectOutputStream(sock.getOutputStream());
         System.out.println("Test 3");
  </code></pre>
  
  <p>I have a lot of Legend of Zelda references in my server source code and the code is rather large. The previous source code is for the client and although the server connects here is where I call ObjectOutputStream.</p>
  
  <pre><code>    ObjectOutputStream ganandorf;
  
      for(int i = 0; i &lt; clients.size(); i++)
      {
         try
         {
              ganandorf = new ObjectOutputStream(clients.get(i).getOutputStream());
              ganandorf.write(1);
              ganandorf.flush();
              ganandorf.writeObject(something);
              ganandorf.flush();
         }
  </code></pre>