0

I have a method to write data to a file.

public void writeCSFFileData(List<String> fileData){
    try {
        CsvListWriter csvWriter = new CsvListWriter(new FileWriter("/path/file.csv"), CsvPreference.STANDARD_PREFERENCE);
        csvWriter.write(fileData);
        csvWriter.close();

    } catch (Exception e) {
        SimpleLogger.getInstance().writeError(e);
    }

The above method is called several times to write to a file. But, each time the file is not appended instead it is overwritten.

Thanks in advance.

Rohith
  • 43
  • 2
  • 10
  • 1
    possible duplicate of [SuperCSV append rather than overwrite?](http://stackoverflow.com/questions/15729977/supercsv-append-rather-than-overwrite) – James Bassett Oct 12 '14 at 12:00

1 Answers1

0

I found the solution myself, I just need to add true in FileWriter to append the data.

Ex: new FileWriter("/path/file.csv",true)

Rohith
  • 43
  • 2
  • 10