Java IO Tutorial - Java FileWriter(File file, boolean append) Constructor








Syntax

FileWriter(File file, boolean append) constructor from FileWriter has the following syntax.

public FileWriter(File file,   boolean append)   throws IOException

Example

In the following code shows how to use FileWriter.FileWriter(File file, boolean append) constructor.

import java.io.File;
import java.io.FileWriter;
/*from   w w  w  .j a  v a  2s .  com*/
public class Main {
  public static void main(String[] args) throws Exception {
    FileWriter fileWriter = new FileWriter(new File("c:/abc.txt"),true);
    fileWriter.append("java2s.com");
    fileWriter.close();
    
  }
}