Read a File in Java

We come across many times that we need to read from a file in Java. In Java we can do this using FileReader class.

FileReader is a Class for reading character files. This class provides many constructors and methods.

In Java, we can read a file using different ways. Here we will use read() method from FileReader class to read from file. This method reads a single character. This method returns the character read or -1 if the end of the stream has been reached.


Let’s see how to read from a file with an example.

Using FileReader:


Related posts

Leave a Comment