Wrap FileReader with BufferedReader : FileReader « File « Java Tutorial






import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class SourceReader {
  public static void main(String[] arguments) {
    try {
      FileReader file = new FileReader("SourceReader.java");
      BufferedReader buff = new BufferedReader(file);
      boolean eof = false;
      while (!eof) {
        String line = buff.readLine();
        if (line == null)
          eof = true;
        else
          System.out.println(line);
      }
      buff.close();
    } catch (IOException e) {
      System.out.println("Error - " + e.toString());
    }
  }
}








11.30.FileReader
11.30.1.FileReader
11.30.2.Use a FileReader to display a text file.
11.30.3.Read the file one buffer at a time
11.30.4.Read file upside down
11.30.5.Loading text from a file
11.30.6.Wrap FileReader with BufferedReader