title: BufferInputStream vs ByteArrayInputStream
body: <p>Here are three ways to read an entire file into memory before processing it:</p>
  
  <p>Approach A:</p>
  
  <pre><code>fis = new FileInputStream(file);
  bis = new BufferedInputStream(fis);
  dis = new DataInputStream(bis);
  </code></pre>
  
  <p>Approach B:</p>
  
  <pre><code>ByteArrayInputStream bi =
      new ByteArrayInputStream(
          org.apache.commons.io.FileUtils.readFileToByteArray(file))
  </code></pre>
  
  <p>Approach C:</p>
  
  <pre><code>File file = new File(yourFileName);
  RandomAccessFile ra = new RandomAccessFile(yourFileName, "rw"):
  byte[] b = new byte[(int)file.length()];
  try {
      ra.read(b);
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Why would I prefer one approach over another?<br>
  Are there any specific use-cases that call for one approach over another?<br>
  Why not use a fixed-length <code>byte[]</code> instead?</p>