title: Writing large files using BufferedOutputStream
body: <p>I am trying read and write large files (larger than 100 MBs) using <code>BufferedInputStream</code>   &amp; <code>BufferedOutputStream</code>. I am getting Heap Memory issue &amp; OOM exception.<br>
  The code looks like :</p>
  
  <pre><code>BufferedInputStream buffIn = new BufferedInputStream(iStream);
  /** iStream is the InputStream object  **/
  
  BufferedOutputStream buffOut=new BufferedOutputStream(new FileOutputStream(file));
  byte []arr = new byte [1024 * 1024];
  int available  = -1;
  while((available = buffIn.read(arr)) &gt; 0) {   
      buffOut.write(arr, 0, available); 
  }      
  buffOut.flush();
  buffOut.close();        
  </code></pre>
  
  <p>My question is when we use the <code>BufferedOutputStreeam</code> is it holding the memory till the full file is written out ?<br>
  What is the best way to write large files using <code>BufferedOutputStream</code>?    </p>