I have a very large HashMap of the format HashMap<String, List<String>>, and I want to serialize it using BufferedOutputStream because I think that it will be more efficient than with a regular OutputStream.
But how do I divide the HashMap in chunks of the size of the buffer? Should I just iterate through the HashMap?
If you plan to write into a local file you need to chain
FileOutputStream,BufferedOutputStreamandObjectOutputStream. With below setupBufferedOutputStreamshould minimize direct writes to the file system using default buffer of 8192 bytes.Unless the output file is too big there is no need for further chunking.