FileWriter: close() : FileWriter « java.io « Java by API






FileWriter: close()

 
 
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

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