I am using this method to write to a CSV file. Every time I run my code it removes all previous data from the file instead of adding to it.
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
File dir = new File(".");
String loc = dir.getCanonicalPath() + File.separator + "Code.txt";
FileWriter fstream = new FileWriter(loc, true);
BufferedWriter out = new BufferedWriter(fstream);
out.write("something");
out.newLine();
//close buffer writer
out.close();
}
}```