title: Socket Inputstream doesn't return -1 at the end of stream
body: <p>This is a code snippet where the problem is happening:</p>
  
  <pre><code>public static byte[] copyLargeExt(InputStream input) throws IOException {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          byte[] buffer = new byte[1024*8];
          int n = 0;
          while(-1 != (n = input.read(buffer))) {
              baos.write(buffer, 0, n);
          // i just append this pattern ({###END###}) to force the break  
             /*if(baos.toString(UTF8.name()).endsWith("{###END###}")) {
                  break;
              }*/
          }
          return baos.toByteArray();
      }
  </code></pre>
  
  <p>Can someone help me?</p>