List of usage examples for java.io PipedReader read
public synchronized int read() throws IOException
From source file:Main.java
public static void main(String[] args) throws IOException { PipedWriter pw = new PipedWriter(); PipedReader pr = new PipedReader(pw); int ch;/*from w w w. j av a2s. c o m*/ try { for (int i = 0; i < 15; i++) pw.write(" A" + i + '\n'); while ((ch = pr.read()) != -1) System.out.print((char) ch); } catch (IOException e) { } }
From source file:Main.java
public static void main(String[] args) { char[] c = { 'h', 'e', 'l', 'l', 'o' }; PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {//from ww w . jav a 2s. com // connect the reader and the writer writer.connect(reader); writer.write(c, 0, 3); // print what we wrote for (int i = 0; i < 3; i++) { System.out.println((char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {/*from w w w . j a v a 2 s .co m*/ // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {/*from ww w. java 2 s .c o m*/ // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {/*from www . j ava 2 s .c o m*/ // connect the reader and the writer writer.connect(reader); writer.write(70); writer.write(71); // print what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {/*from ww w .j ava 2 s .c o m*/ // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } reader.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {//ww w .j a va2 s .c om // connect the reader and the writer writer.connect(reader); writer.write('A'); writer.write('B'); // print what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {/*from ww w. j a va2 s . c o m*/ // connect the reader and the writer writer.connect(reader); writer.write(70); writer.write(71); writer.close(); // print what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {/*from w w w .java 2s . c om*/ PipedReader reader = new PipedReader(); PipedWriter writer = new PipedWriter(reader); // connect the reader and the writer writer.connect(reader); writer.write('A'); writer.write('B'); // print what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } writer.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {/*from ww w.java 2 s. co m*/ // connect the reader and the writer writer.connect(reader); writer.write(70); writer.write(71); // flush the writer writer.flush(); // print what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } } catch (IOException ex) { ex.printStackTrace(); } }