Java BufferedReader mark(int readAheadLimit) method example

HQ » Java Tutorial » » BufferedReader » mark(int readAheadLimit) method example
Java BufferedReader mark(int readAheadLimit) method example 2018-02-16T07:27:50+00:00 mark(int readAheadLimit)

Description :

This java tutorial shows how to use the mark() method of BufferedReader class of package. This method returns void and mark the present position in the stream. Make a note that a subsequent call to reset() will attempt to re position the stream to this point. This method overrides the mark() method of Reader class.

Method Syntax :

public void mark(int readAheadLimit) throws IOException

Parameter Input :

DataType Parameter Description
int readAheadLimit this parameter input is the limit on the number of characters that may be read but preserving the current mark.

Method Returns :

This method returns void but mark the present position on the stream.

Compatibility Version :

Requires Java 1.1 and up

Exception :


– this exception will be thrown if the readAheadLimit is negative number or less than 0


– the IOException will be thrown my mark() method if I/O error occurs.

Java Code Example :

This java example source code demonstrates the use of mark() method of BufferedReader class. Basically we mark the stream and use the reset method to go back to the marked index.

Sample Output :

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

Exception Scenario :

Similar Method :

  • N/A

Suggested Reading List :

References :

Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.