List of usage examples for java.io StringReader StringReader
public StringReader(String s)
From source file:Main.java
public static void main(String[] args) throws IOException { StringReader in2 = new StringReader("a bc ddd"); int c;/*from w w w .j a v a 2 s . c o m*/ while ((c = in2.read()) != -1) System.out.print((char) c); }
From source file:Main.java
public static void main(String[] argv) throws IOException { StringReader stringReader = new StringReader("java2s.com"); System.out.println(stringReader.read()); stringReader.close();//from w w w .j a v a 2 s. com }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com"; StringReader sr = new StringReader(s); PushbackReader pr = new PushbackReader(sr, 20); try {/*from ww w .j a va 2s . c om*/ for (int i = 0; i < 5; i++) { char c = (char) pr.read(); System.out.println(c); } pr.mark(5); pr.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) throws IOException { StringReader stringReader = new StringReader("java2s.com"); stringReader.skip(2);// w w w. j ava 2 s. co m System.out.println(stringReader.read()); stringReader.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com"; Reader reader = new StringReader(s); try {/* w ww . java2 s. c om*/ // read the first five chars for (int i = 0; i < 5; i++) { char c = (char) reader.read(); System.out.println(c); } reader.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com"; StringReader sr = new StringReader(s); PushbackReader pr = new PushbackReader(sr, 20); try {// ww w.j a v a 2 s . c o m for (int i = 0; i < 5; i++) { char c = (char) pr.read(); System.out.println(c); } System.out.println("" + pr.markSupported()); pr.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com"; StringReader sr = new StringReader(s); PushbackReader pr = new PushbackReader(sr, 20); char cbuf[] = new char[5]; try {/*from w ww . j a va2s . c om*/ System.out.println(pr.read(cbuf)); System.out.println(cbuf); pr.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com"; StringReader sr = new StringReader(s); // create a new PushBack reader based on our string reader PushbackReader pr = new PushbackReader(sr, 20); try {/*from w ww. ja va 2 s .com*/ // read the first five chars for (int i = 0; i < 5; i++) { char c = (char) pr.read(); System.out.println(c); } pr.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com"; Reader reader = new StringReader(s); try {/*from www.j av a 2 s . c o m*/ // read the first five chars for (int i = 0; i < 5; i++) { char c = (char) reader.read(); System.out.println(c); } reader.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com"; Reader reader = new StringReader(s); try {/* w w w. j a v a2 s . c o m*/ // read the first five chars for (int i = 0; i < 5; i++) { char c = (char) reader.read(); // skip a char every time reader.skip(1); System.out.println(c); } reader.close(); } catch (IOException ex) { ex.printStackTrace(); } }