Read Text File using BufferedReader Example

In java, there are many ways to read a text file. We can read text file either line-by-line or character-by-character. Here is the simplest program of reading a text file line-by-line in java.

To read a text file line-by-line in java we use BufferedReader. As BufferedReader cannot directly communicate with File, BufferedReader can only communicate with file via some Reader, so first we will create a FileReader object.

BufferedReader have readLine() method. Which reads next line and return as a string. When there is no next line (End of File) then readLine() return null value.