Example usage for java.io PipedReader connect

List of usage examples for java.io PipedReader connect

Introduction

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

Prototype

public void connect(PipedWriter src) throws IOException 

Source Link

Document

Causes this piped reader to be connected to the piped writer src.

Usage

From source file:Main.java

public static void main(String[] args) {

    try {//from   w w  w .  ja  v a 2 s  .  c o m
        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 {/*from ww w .j  a  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  .j a v a  2s  . 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) {

    try {/*from   ww w . j av  a  2s  .  c  om*/
        PipedWriter writer = new PipedWriter();
        PipedReader reader = new PipedReader(writer, 100);

        // 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 {//from   www . j av  a2  s  .c  o  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 {/*from   w w  w .  ja  v  a 2s.  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  ww w  .  j a  va  2s.  co  m
        // connect the reader and the writer
        reader.connect(writer);

        writer.write(70);
        writer.write(71);

        // read into a char array
        char[] b = new char[2];
        reader.read(b, 0, 2);

        // print the char array
        for (int i = 0; i < 2; i++) {
            System.out.println(b[i]);
        }

    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    PipedWriter writer = new PipedWriter();
    PipedReader reader = new PipedReader(100);

    try {//from   www  . j  ava  2 s  .c om
        // 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();
    }
}