The
close() method of
BufferedWriter class in Java is used to flush the characters from the buffer stream and then close it. Once the stream is closed further calling the methods like write() and append() will throw the exception.
Syntax:
public void close()
Parameters: This method does not accept any parameter.
Return value: This method does not return any value.
Exceptions: This method throws
IOException if an I/O error occurs.
Below programs illustrate close() method in BufferedWriter class in IO package:
Program 1:
Program 2: