Java Bulk WRITE

java

Solution

You're probably interested in a `FileChannel`. `Channel`s were designed to perform bulk IO operations to and from `Buffer`s.

Ex:

FileChannel fileOut = new FileOutputStream(file).getChannel();
fileOut.write(ByteBuffer.wrap("Whatever you want to write".getBytes()));

Problem

I have to write a series of characters in the disk file and I want to use bulk writing to reduce disk I/O. Currently, I am using File Writer class. However, it is too slow. Can anybody help me how to perform bulk write in Java like maintaining a large buffer and periodically flush it.

Original source