Example usage for java.io PipedOutputStream PipedOutputStream

List of usage examples for java.io PipedOutputStream PipedOutputStream

Introduction

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

Prototype

public PipedOutputStream() 

Source Link

Document

Creates a piped output stream that is not yet connected to a 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(out, 200);
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    PipedOutputStream out = new PipedOutputStream();

    PipedInputStream in = new PipedInputStream(out);
}

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. j av  a 2s .  c om*/

    // 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  ww . ja  v a  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(200);

    // connect input and output
    in.connect(out);//from w  w w.ja  v a2 s  . c  om

    // 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  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  ww w . jav  a 2  s.co m*/

    // write something
    out.write(70);
    out.write(71);

    // read what we wrote into an array of bytes
    byte[] b = new byte[2];
    in.read(b, 0, 2);

    System.out.println(new String(b));
    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 om

    // 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 main(String[] args) throws Exception {

    PipedOutputStream out = new PipedOutputStream();
    Main in = new Main();

    // connect input and output
    in.connect(out);/*from   w  w  w  .  j ava2s.  c o  m*/

    // write something
    out.write(70);
    out.write(71);

    // receive a byte
    in.receive(71);
    in.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    PipedOutputStream out = new PipedOutputStream();
    Main in = new Main();

    out.connect(in);//ww  w  . j  ava 2s  .  com

    out.write(70);
    out.write(71);
    out.write(72);

    out.flush();

    for (int i = 0; i < 3; i++) {
        System.out.println((char) in.read());
    }
    out.close();
}