Home » Java PipedReader Class

Java PipedReader Class

by Online Tutorials Library

Java – PipedReader

The PipedReader class is used to read the contents of a pipe as a stream of characters. This class is used generally to read text.

PipedReader class must be connected to the same PipedWriter and are used by different threads.

Constructor

Constructor Description
PipedReader(int pipeSize) It creates a PipedReader so that it is not yet connected and uses the specified pipe size for the pipe’s buffer.
PipedReader(PipedWriter src) It creates a PipedReader so that it is connected to the piped writer src.
PipedReader(PipedWriter src, int pipeSize) It creates a PipedReader so that it is connected to the piped writer src and uses the specified pipe size for the pipe’s buffer.
PipedReader() It creates a PipedReader so that it is not yet connected.

Method

Modifier and Type Method Method
void close() It closes this piped stream and releases any system resources associated with the stream.
void connect(PipedWriter src) It causes this piped reader to be connected to the piped writer src.
int read() It reads the next character of data from this piped stream.
int read(char[] cbuf, int off, int len) It reads up to len characters of data from this piped stream into an array of characters.
boolean ready() It tells whether this stream is ready to be read.

Example

Output:

I love my country  

You may also like