Append or add some contents to the file : FileWriter « File « Java Tutorial






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();
  }
}








11.33.FileWriter
11.33.1.FileWriter
11.33.2.Use FileWriter to write an array of strings to a file.
11.33.3.Append or add some contents to the file
11.33.4.Wrap FileWriter with BufferedWriter