List of usage examples for java.io PipedWriter write
public void write(int c) throws IOException
char
to the piped output stream. From source file:Main.java
public static void main(String[] args) { try {/*w w w. ja v a2s .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) throws IOException { PipedWriter pw = new PipedWriter(); PipedReader pr = new PipedReader(pw); int ch;//from ww w . ja va 2s . c om 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) { PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(); try {//from w ww . ja v a2 s . c om // 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 . jav a 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 ww w . ja v a 2 s. co m // 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) { try {//from w ww . j a v a2 s. com PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(writer); // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // check if reader is ready to read System.out.println(reader.ready()); // print the char array for (int i = 0; i < 2; i++) { System.out.println("" + (char) reader.read()); } reader.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 {/* ww w .j a va 2 s . com*/ // 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 w ww . j av a2s .co m*/ // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // check if reader is ready to read System.out.println(reader.ready()); // print the char array 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 {// w ww .jav 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()); } 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 {//from w w w .ja v a2 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(); } }