Example usage for java.io PipedOutputStream write

List of usage examples for java.io PipedOutputStream write

Introduction

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

Prototype

public void write(int b) throws IOException 

Source Link

Document

Writes the specified byte to the piped output stream.

Usage

From source file:Main.java

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

    out.connect(in);//from   w  w w .  ja v a  2 s.  c o  m

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

From source file:Main.java

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

    out.connect(in);//from  w  w  w . ja  v a 2s  .  c o  m

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

    out.flush();

    // print what we wrote
    for (int i = 0; i < 2; i++) {
        System.out.println((char) in.read());
    }
    out.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 a v  a2 s  .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();

    // connect input and output
    out.connect(in);/*from w  ww. j  a  va  2s .com*/

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

    // print what we wrote
    for (int i = 0; i < 2; i++) {
        System.out.println("" + (char) in.read());
    }
    out.close();
}

From source file:Main.java

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

    // create a new Piped input and Output Stream
    PipedOutputStream out = new PipedOutputStream();
    Main in = new Main();

    // connect input and output
    out.connect(in);//from w w  w  .ja  va 2  s . c  o  m

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

    out.close();

    // print what we wrote
    for (int i = 0; i < 2; i++) {
        System.out.println("" + (char) in.read());
    }

}

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.  java  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);/*  w  w  w .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();

    // connect input and output
    in.connect(out);//from w  w w.  j a  v  a 2 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);//  ww w  .  j ava  2s . c o  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(200);

    // connect input and output
    in.connect(out);/*from  ww  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();
}