Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing at the end of a file via opencsv

Tags:

java

csv

opencsv

I'm using opencsv and want to write to a .csv file through multiple sessions. However every time I start a new CSVWriter the old file gets erased. Can I change the behavior of the CSVWriter to write at the end of the file instead of replacing the file?

like image 832
Christian Avatar asked Sep 18 '10 11:09

Christian


1 Answers

There's an option in the FileWriter instead of the CSVWriter to append at the end of the file.

This code makes it work:

mFileWriter = new FileWriter(file_path, true);
mCsvWriter = new CSVWriter(mFileWriter);
like image 104
Christian Avatar answered Sep 21 '22 05:09

Christian