The
mark() method of
StringReader Class in Java is used to mark the stream as the checkpoint from where the stream read will start, once reset() is called. This method is not supported by all subclasses of StringReader class.
Syntax:
public void mark(int readAheadLimit)
Parameters: This method accepts a mandatory parameter
readAheadLimit which is the limit on the number of characters that may be read while still preserving the mark. After reading this many characters, attempting to reset the stream may fail.
Return Value: This method do not returns any value.
Exception: This method throws IOException if some error occurs while input output or the mark() method is not supported.
Below methods illustrates the working of mark() method:
Program 1:
Program 2: