Java: Text file - Input

Background:
  • try and catch statements are used to catch errors when reading from a file.
  • two Java classes are used in this example:
    • FileReader: sets up a text file for reading. This file is a required parameter in the BufferedReader class
    • BufferedReader:  reads text from an character input stream
      • BufferedReader methods used in the example: close() readline()
Sample Code:
This sample code displays each line in the BufferedReader reads.

Comments