BufferedReader close() method in Java with Examples
The close() method of BufferedReader class in Java is used to close the stream and release all the system resources associated with the stream operations.
public void close() throws IOException
Parameters: This method does not accept any parameter.
Return value: This method does not return any value.
Exception: This method throws IOException if an I/O error occurs.
Below programs illustrate close() method in BufferedReader class in IO package:
Program 1: Assume the existence of the file “c:/demo.txt”.
Program 2: Assume the existence of the file “c:/demo.txt”.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.