VOOZH about

URL: https://www.geeksforgeeks.org/java/stringreader-markint-method-in-java-with-examples/

⇱ StringReader mark(int) method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

StringReader mark(int) method in Java with Examples

Last Updated : 11 Jul, 2025
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:
Output:
GeeksForGe
eks??
Program 2:
Comment