List of usage examples for java.io CharArrayReader CharArrayReader
public CharArrayReader(char buf[])
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'A', 'B', 'C', 'D', 'E' }; CharArrayReader car = new CharArrayReader(ch); }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'H', 'E', 'L', 'L', 'O' }; CharArrayReader car = new CharArrayReader(ch); car.close();/*from ww w . ja va2s .c o m*/ // read the character array stream System.out.println(car.read()); }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'A', 'B', 'C', 'D', 'E' }; CharArrayReader car = new CharArrayReader(ch); // test whether the stream is ready to be read boolean isReady = car.ready(); // print//from w w w .j ava 2 s. co m System.out.println("Ready ? " + isReady); }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'A', 'B', 'C', 'D', 'E' }; CharArrayReader car = new CharArrayReader(ch); int value = 0; while ((value = car.read()) != -1) { System.out.print((char) value); }/*from w ww.j a v a 2s . c o m*/ car.reset(); while ((value = car.read()) != -1) { System.out.print((char) value); } }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'H', 'E', 'L', 'L', 'O' }; CharArrayReader car = new CharArrayReader(ch); int value = 0; // read till the end of the file while ((value = car.read()) != -1) { char c = (char) value; // print the character System.out.print(c + " : "); // print the integer System.out.println(value); }/*from w w w . j av a 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'A', 'B', 'C', 'D', 'E' }; CharArrayReader car = new CharArrayReader(ch); int value = 0; // read till the end of the stream while ((value = car.read()) != -1) { // convert integer to char char c = (char) value; // print characters System.out.print(c + "; "); // skip single character long l = car.skip(1); System.out.println("Characters Skipped : " + l); }/*from w w w .j a va2s .c om*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'A', 'B', 'C', 'D', 'E' }; CharArrayReader car = new CharArrayReader(ch); // read and print the characters from the stream System.out.println(car.read()); System.out.println(car.read()); // mark() is invoked at this position car.mark(0);//from w ww. j a va 2 s. c o m System.out.println("Mark() is invoked"); System.out.println(car.read()); System.out.println(car.read()); // reset() is invoked at this position car.reset(); System.out.println("Reset() is invoked"); System.out.println(car.read()); System.out.println(car.read()); System.out.println(car.read()); }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'A', 'B', 'C', 'D', 'E' }; CharArrayReader car = new CharArrayReader(ch); // verifies if the stream support mark() method boolean bool = car.markSupported(); System.out.println("Is mark supported : " + bool); System.out.println("Proof:"); // read and print the characters from the stream System.out.println(car.read()); System.out.println(car.read()); // mark() is invoked at this position car.mark(0);/*from w w w .j a v a2 s .c om*/ System.out.println("Mark() is invoked"); System.out.println(car.read()); System.out.println(car.read()); // reset() is invoked at this position car.reset(); System.out.println("Reset() is invoked"); System.out.println(car.read()); System.out.println(car.read()); System.out.println(car.read()); }
From source file:Main.java
public static void main(String[] args) throws Exception { char[] ch = { 'H', 'E', 'L', 'L', 'O' }; char[] d = new char[5]; CharArrayReader car = new CharArrayReader(ch); // read character to the destination buffer car.read(d, 3, 2);//from ww w . j av a 2s .com // for every character in the buffer for (char c : d) { int i = (int) c; if (i == 0) { System.out.println("0"); } else { System.out.println(c); } } }
From source file:Main.java
public static void main(String args[]) throws IOException { String tmp = "abcdefghijklmnopqrstuvwxyz"; int length = tmp.length(); char c[] = new char[length]; tmp.getChars(0, length, c, 0);/*from w w w . j a v a 2 s . c om*/ CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 0, 5); int i; while ((i = input1.read()) != -1) { System.out.print((char) i); } while ((i = input2.read()) != -1) { System.out.print((char) i); } }