FileWriter: flush()

public void flush() throws IOException
Flush the stream.

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();
  }
}
Home 
  Java Book 
    File Stream  

FileWriter:
  1. FileWriter
  2. new FileWriter(File file)
  3. new FileWriter(String string)
  4. new FileWriter(String fileName, boolean append)
  5. FileWriter: close()
  6. FileWriter: flush()
  7. FileWriter: write(int i)