title: How to avoid OutOfMemoryError when using Bytebuffers and NIO?
body: <p>I'm using <code>ByteBuffers</code> and <code>FileChannels</code> to write binary data to a file. When doing that for big files or successively for multiple files, I get an <code>OutOfMemoryError</code> exception.
  I've read elsewhere that using <code>Bytebuffers</code> with NIO is broken and should be avoided. Does any of you already faced this kind of problem and found a solution to efficiently save large amounts of binary data in a file in java?</p>
  
  <p>Is the jvm option <code>-XX:MaxDirectMemorySize</code> the way to go?</p>