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  va 2s.  c om
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();
    
  }
}