I'm using ByteBuffers
and FileChannels
to write binary data to a file. When doing that for big files or successively for multiple files, I get an OutOfMemoryError
exception.
I've read elsewhere that using Bytebuffers
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?
Is the jvm option -XX:MaxDirectMemorySize
the way to go?