It is therefore advisable to wrap BufferedReader in Java around any Reader whose read() operations may be costly, such as java FileReaders and InputStreamReaders. A typical usage would involve passing the file path to the BufferedReader in Java as follows: This basically loads your file in the objReader.Now, you will need to iterate through the contents of the file and print it. The while loop in the below code will read the file until it has reached the end of file strCurrentLine reads the current line and the Java readLine function objReader.readLine() returns a string. Hence, the loop will iterate until it’s not null.

BufferedReader Example:

Below code is a Java BufferedReader example which shows the complete implementation: Note: The above code has some very important handlings especially in the finally block of the code. This code will ensure that the memory management is done efficiently and the objReader.close() method is called that releases the memory.

BufferedReader JDK7 Example:

Below is the example of Java Read Files using BufferedReader class