List of usage examples for java.io FilterReader read
public int read() throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { int i = 0;//w w w . ja v a2 s . com Reader r = new StringReader("ABCDEFG"); // create new filter reader FilterReader fr = new FilterReader(r) { }; // read till the end of the stream while ((i = fr.read()) != -1) { char c = (char) i; System.out.println(c); } }
From source file:Main.java
public static void main(String[] args) throws Exception { int i = 0;/*from w ww . ja v a 2 s.co m*/ char c; // create new reader Reader r = new StringReader("ABCDEF"); // create new filter reader FilterReader fr = new FilterReader(r) { }; // read till the end of the stream while ((i = fr.read()) != -1) { // converts integer to character c = (char) i; // print System.out.println("Character read: " + c); } }
From source file:Main.java
public static void main(String[] args) throws Exception { int i = 0;/*from w w w. j a v a2s . c om*/ // create new reader Reader r = new StringReader("from java2s.com"); // create new filter reader FilterReader fr = new FilterReader(r) { }; // read till the end of the filter reader while ((i = fr.read()) != -1) { // convert integer to character char c = (char) i; // prints System.out.println("Character read: " + c); // number of characters actually skipped long l = fr.skip(2); // prints System.out.println("Character skipped: " + l); } }
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 w w .j av a 2s . co m // 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 w w .j a v a2 s . c o m // 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()); }