O'Reilly logo

Java Programming for Beginners by Mark Lassoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The FileReader and BufferedReader class

Here, you will learn about the FileReader class with the help of the code we already have (see the preceding code). Firstly, go through the following steps:

  1. I've declared FileWriter and FileReader objects for us. FileReader is a sister class of FileWriter. It's capable of, believe it or not, reading text input from files, and it's constructed in a very similar manner. It expects to be given a file to be associated with throughout its life when it's constructed.
  2. Rather than simply giving the FileReader and FileWriter paths to these files, I've chosen to create File objects. The Java file object is simply a reference to an existing file, and we tell that file what file it will reference when it's created ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required