Append or add some contents to the file
import java.io.File;
import java.io.FileWriter;
public class Main {
public static void main(String[] args) throws Exception{
File file = new File("user.txt");
FileWriter writer = new FileWriter(file, true);
writer.write("username=java;password=secret" + System.getProperty("line.separator"));
writer.flush();
writer.close();
}
}
Related examples in the same category