Java IO Tutorial - Java FileReader(File file) Constructor








Syntax

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

public FileReader(File file)   throws FileNotFoundException

Example

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

//from w  w w.  jav  a2 s .  c  o  m
import java.io.File;
import java.io.FileReader;

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