Example usage for java.io PipedReader read

List of usage examples for java.io PipedReader read

Introduction

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

Prototype

public synchronized int read() throws IOException 

Source Link

Document

Reads the next character of data from this piped stream.

Usage

From source file:Main.java

public static void main(String[] args) {

    try {/*from  w  w w.  j a va  2s  . 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) {

    try {/*  w w w. j ava2s .com*/
        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   w w w  . java 2 s  . co  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(100);

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