title: Memory issues with InputStream in Java
body: <p>I need to read a file into an array of Bytes.The entire file needs to be read into the array. The problem is I am getting an OutOfMemory Error since the file size is too large. Increasing -XmX does not seem to have any effect. Here is the code snippet :</p>
  
  <pre><code>InputStream in = new FileInputStream(file);
  long length = file.length();                        
  byte[] out = new byte[(int)length]; 
  // Process the byte array
  </code></pre>
  
  <p>The problem occurs during the byte array instantion. Is there a less memory intensive workaround to this issue?</p>