Java StringReader.mark(int readAheadLimit)

Syntax

StringReader.mark(int readAheadLimit) has the following syntax.

public void mark(int readAheadLimit)  throws IOException

Example

In the following code shows how to use StringReader.mark(int readAheadLimit) method.


//  ww w. ja v a2  s. c  om
import java.io.IOException;
import java.io.StringReader;

public class Main {
  public static void main(String[] argv) throws IOException{
    StringReader stringReader = new StringReader("java2s.com");
    
    stringReader.mark(2);
    
    System.out.println(stringReader.markSupported());
    
    System.out.println(stringReader.read());
    
    stringReader.reset();
    
    stringReader.close();
  }
}

The code above generates the following result.