Replace all existing content with new content.
new FileWriter(file);
Save existing content and add new content at the end of the file.
new FileWriter(file,true);
Example:
FileWriter fileWritter = new FileWriter(file.getName(),true);
BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
bufferWritter.write(data);
bufferWritter.close();
source
share