Java IO Tutorial - Java FileWriter(String fileName) Constructor








Syntax

FileWriter(String fileName) constructor from FileWriter has the following syntax.

public FileWriter(String fileName)   throws IOException

Example

In the following code shows how to use FileWriter.FileWriter(String fileName) constructor.

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