I am trying to understand what would be the difference between calling FileChannel.write in short successions with a 16k buffer AND mapping multiple ByteBuffers with an append size of 16k as described here: https://stackoverflow.com/a/7367952/962872
I would think that the mapped bytebuffer approach produces a lot of garbage as you discard the MappedByteBuffers after each append. And I am not sure it is faster either. And you still have to do a bunch of mapping operations... (one per append).
Or perhaps you should map a huge ByteBuffer (as big as possible) and just keep writing to this MappedByteBuffer?
I am using the FileChannel.write approach with a Java-side 16kb buffer as a "fast" way to write a file but I want to make sure I am not missing something faster/better.
Can anyone shed a light?