title: What is wrong with FileInputStream.read(byte[])?
body: <p>In response to <a href="https://stackoverflow.com/questions/6058003/beautiful-way-to-read-file-into-byte-array-in-java/6058083#6058083">my answer to a file-reading question</a>, a commenter stated that <code>FileInputStream.read(byte[])</code> is "not guaranteed to fill the buffer."</p>
  
  <pre><code>File file = /* ... */  
  long len = file.length();
  byte[] buffer = new byte[(int)len];
  FileInputStream in = new FileInputStream(file);
  in.read(buffer);
  </code></pre>
  
  <p>(The code assumes that the file length does not exceed 2GB) </p>
  
  <p>Apart from an <code>IOException</code>, what could cause the <code>read</code> method to not retrieve the entire file contents?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The idea of the code (and the goal of the OP of the question I answered) is to read the entire file into a chunk of memory in one swoop, that's why <i>buffer_size</i> = <i>file_size</i>.</p>