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(PipedWriter src, int pipeSize) throws IOException 

Source Link

Document

Creates a PipedReader so that it is connected to the piped writer src and uses the specified pipe size for the pipe's buffer.

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, 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:com.github.jferard.pgloaderutils.loader.CSVCleanerFileReader.java

public CSVCleanerFileReader(CSVParser parser, CSVRecordCleaner recordCleaner) throws IOException {
    this.recordCleaner = recordCleaner;
    PipedWriter pipedWriter = new PipedWriter();
    this.modifiedStreamReader = new PipedReader(pipedWriter, BUFFER_SIZE);

    this.parser = parser;
    this.printer = new CSVPrinter(pipedWriter, CSVFormat.RFC4180);
    this.logger = Logger.getLogger("Cleaner");
}