title: Infinite Loop in Input Stream
body: <p>I am reading from an input stream which I am receiving from a server side of a socket. I have no way of knowing what the size of my response will be and I am reading into a byte array this is the code </p>
  
  <pre><code>public static String readString(InputStream inputStream) throws IOException {
  
      ByteArrayOutputStream into = new ByteArrayOutputStream();
      byte[] buf = new byte[4096];
      for (int n; 0 &lt; (n = inputStream.read(buf));) {
          System.out.println("Got to this point n is "+n);
          into.write(buf, 0, n); 
      }
      into.close();
      System.out.println("passed this point");
      return new String(into.toByteArray(), AddATudeMessage.CHARENC); 
  }
  </code></pre>
  
  <p>write now the numbers 11 and 235 get printed to the console so I assume the server is still writing output into the input stream. it however gets stuck at 235 and nothing seemes to be happending.  I tried pausing the main execution thread for as much as 20 seconds at which point i receive 241 bytes from the server  and then the same infinite loop reoccurs anyone know what's going on</p>