Example usage for java.io PipedReader PipedReader

List of usage examples for java.io PipedReader PipedReader

Introduction

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

Prototype

public PipedReader() 

Source Link

Document

Creates a PipedReader so that it is not yet #connect(java.io.PipedWriter) connected .

Usage

From source file:Main.java

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

    try {// w  w  w.j  a  va  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) {
    PipedWriter writer = new PipedWriter();
    PipedReader reader = new PipedReader();

    try {/*ww  w. ja  va2s  . 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());
        }

    } 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 . j  a  v  a  2s. co m*/
        // connect the reader and the writer
        writer.connect(reader);

        writer.write('A');
        writer.write('B');

        // print 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 {// w  ww.  j ava2s . c o m
        // connect the reader and the writer
        writer.connect(reader);

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

        // print 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 {/* www . j  a  v  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 {//w w  w.ja  v  a  2 s .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  w w w . j  a va 2  s.  c  om
        // 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();

    try {/*from   w w  w  .  j av  a2s.c o  m*/
        // connect the reader and the writer
        writer.connect(reader);

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

        writer.close();

        // print 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 {/*  w  w w.  jav a 2s.co  m*/
        // connect the reader and the writer
        writer.connect(reader);

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

        // flush the writer
        writer.flush();

        // print 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 {//ww  w.  ja va2s.  c o m
        PipedReader reader = new PipedReader();
        PipedWriter writer = new PipedWriter(reader);

        // connect the reader and the writer
        writer.connect(reader);

        writer.write('A');
        writer.write('B');

        // print what we wrote
        for (int i = 0; i < 2; i++) {
            System.out.println((char) reader.read());
        }
        writer.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}