I need generate report of some big amount of data into csv file. I want avoid loading all data into memory and flush them all. My preferable way is create csv header and next in sequence write data into csv.
I'm using csv printer of apache csv which can create csv line with some settings. But when I call after every write flush writing is too slow.
Do you have any advice how to solve that task?
BufferedWriterJava offers the
BufferedWriterclass to automatically handle efficient writing to storage. No need for you to callflush. You can set the size of the buffer, but I suggest you start by using the default size.A convenient way to instantiate such a object is by calling
Files.newBufferedWriter.Base your
CSVPrinterobject on theBufferedWriter.