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

ConstructorDescription
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 TypeMethodMethod
voidclose()It closes this piped stream and releases any system resources associated with the stream.
voidconnect(PipedWriter src)It causes this piped reader to be connected to the piped writer src.
intread()It reads the next character of data from this piped stream.
intread(char[] cbuf, int off, int len)It reads up to len characters of data from this piped stream into an array of characters.
booleanready()It tells whether this stream is ready to be read.

Example

Output:

I love my country





Latest Courses