title: Java FileInputStream limited to 65535 bytes
body: <p>I have a program that is opening a fileInputStream, reading it and writing it to an outputstream.  </p>
  
  <p>I'm using AIX.</p>
  
  <p>When I run from terminal, I have no issues.  However, when my third party application runs it, it encounters an issue where the FileInputStream only reads the first 65535 bytes from the file and then the next call to the .read() function returns -1, even though the file is slightly bigger than 65535 bytes (it's 68372 bytes).  This results in a truncated output file.</p>
  
  <p>My question is, what can cause this limitation?  It doesn't appear to be an intrinsic limit of FileInputStream.  I suspect there is a java option being set somewhere but I can't for the life of me determine where.  Could this be an OS limitation somehow?</p>
  
  <p>Here's my basic code:</p>
  
  <pre><code>OutputStream lOut = new FileOutputStream("/home/fileOut.txt");
  FileInputStream fIn = new FileInputStream(new File("/home/fileIn.txt"));
  int ch;
  byte[] buf = new byte[65536];
  
  while((ch = fIn.read(buf)) &gt; 0)
  {
      lOut.write(buf);
  }
  
  fIn.close();
  lOut.close();
  </code></pre>