List of usage examples for java.io FilterReader mark
public void mark(int readAheadLimit) throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { Reader r = new StringReader("ABCDEF"); // create new filter reader FilterReader fr = new FilterReader(r) { };/*from w ww .j a va 2 s . c om*/ // reads and prints FilterReader System.out.println((char) fr.read()); System.out.println((char) fr.read()); // mark invoked at this position fr.mark(0); System.out.println("mark() invoked"); System.out.println((char) fr.read()); System.out.println((char) fr.read()); // reset() repositioned the stream to the mark fr.reset(); System.out.println("reset() invoked"); System.out.println((char) fr.read()); System.out.println((char) fr.read()); }
From source file:Main.java
public static void main(String[] args) throws Exception { Reader r = new StringReader("ABCDEF"); // create new filter reader FilterReader fr = new FilterReader(r) { };/*from w ww.j a v a 2 s. c om*/ // read and print characters one by one System.out.println("Char : " + (char) fr.read()); System.out.println("Char : " + (char) fr.read()); System.out.println("Char : " + (char) fr.read()); // mark is set on the filter reader fr.mark(0); System.out.println("Char : " + (char) fr.read()); System.out.println("reset() invoked"); // reset is called fr.reset(); // read and print characters System.out.println("char : " + (char) fr.read()); System.out.println("char : " + (char) fr.read()); }