Christian Christian - 1 year ago 108
Java Question

Writing at the end of a file via opencsv

I'm using opencsv and want to write to a

file through multiple seasons.
However every time I start a new CSVWriter the old file gets erased.
Can I somehow change the behavior of the CSVWriter to write at the end of the file instead of replacing the file?

Answer Source

It seems that 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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download