Java FileWriter(File file) Constructor

Syntax

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

public FileWriter(File file)   throws IOException

Example

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


import java.io.File;
import java.io.FileWriter;
/*from  w  ww  . ja va2s.  c  o  m*/
public class Main {
  public static void main(String[] args) throws Exception {
    FileWriter fileWriter = new FileWriter(new File("c:/abc.txt"));
    fileWriter.append("java2s.com");
    fileWriter.close();
    
  }
}