List of usage examples for java.io PipedInputStream read
public synchronized int read() throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { PipedOutputStream out = new PipedOutputStream(); PipedInputStream in = new PipedInputStream(); // connect input and output in.connect(out);//from w ww.ja va 2 s . c o m // write something out.write(70); out.write(71); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println("" + (char) in.read()); } in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { PipedOutputStream out = new PipedOutputStream(); PipedInputStream in = new PipedInputStream(); // connect input and output in.connect(out);/*from www.ja va 2s .c o m*/ // write something out.write(70); out.write(71); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println("" + (char) in.read()); } in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { PipedOutputStream out = new PipedOutputStream(); PipedInputStream in = new PipedInputStream(); // connect input and output in.connect(out);/*from www .j a va2 s. c o m*/ // write something out.write(70); out.write(71); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println("" + (char) in.read()); } in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { PipedOutputStream out = new PipedOutputStream(); PipedInputStream in = new PipedInputStream(200); // connect input and output in.connect(out);/*from w w w. ja va 2 s. co m*/ // write something out.write(70); out.write(71); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println("" + (char) in.read()); } in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { PipedOutputStream out = new PipedOutputStream(); PipedInputStream in = new PipedInputStream(); // connect input and output in.connect(out);/*from w w w .j a v a 2s . c o m*/ // write something out.write(70); out.write(71); // print how many bytes are available System.out.println(in.available()); // read what we wrote for (int i = 0; i < 2; i++) { System.out.println("" + (char) in.read()); } in.close(); }
From source file:Main.java
public static void consumeData(PipedInputStream pis) { try {//from w ww . jav a 2 s. c o m int num = -1; while ((num = pis.read()) != -1) { System.out.println("Reading: " + num); } pis.close(); } catch (Exception e) { e.printStackTrace(); } }