Example usage for java.io PipedInputStream read

List of usage examples for java.io PipedInputStream read

Introduction

In this page you can find the example usage for java.io PipedInputStream read.

Prototype

public synchronized int read() throws IOException 

Source Link

Document

Reads the next byte of data from this piped input stream.

Usage

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();
    }

}