Java IO Tutorial - Java FileReader(String fileName) Constructor








Syntax

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

public FileReader(String fileName)   throws FileNotFoundException

Example

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

/*  w w  w  .  j  a va 2 s  .  c  o  m*/
import java.io.FileReader;

public class Main {
  public static void main(String[] args) throws Exception {
    FileReader fileReader = new FileReader("c:/abc.txt");
    System.out.println(fileReader.read());
    fileReader.close();
    
  }
}