java.io.BufferedReader reset()

Description :

This java tutorial shows how to use the reset() method of BufferedReader class of java.io package. This method returns void and resets the stream to the latest mark. Make a note that if mark() method were not invoked prior to calling reset(), IOException will occur.

Method Syntax :

public void reset() throws IOException

Parameter Input :

DataType Parameter Description
N/A N/A N/A

Method Returns :

This method returns void.

Compatibility Version :

Requires Java 1.1 and up

Exception :

IOException

The IOException will be thrown by this method is I/O error occurs. The following cases will be considered as an IOException. if the marked character is invalidated or marked as invalid, and also if the stream is not marked at all.

Java Code Example :

This java example source code demonstrates the use of delimiter() method of Scanner class. Basically it prints the delimiter that is being used by the Scanner object scan which is the default pattern since we didn’t specify delimiter to be used. The code then tokenize the String declared on the constructor of the Scanner object.

Sample Output :

Running the reset() method example source code of BufferedReader class will give you the following output

Exception Scenario :

Similar Method :

  • N/A

Suggested Reading List :

References :