Java - PipedWriter

The PipedWriter class is used to write java pipe as a stream of characters. This class is used generally for writing text. Generally PipedWriter is connected to a PipedReader and used by different threads.

Constructor

ConstructorDescription
PipedWriter()It creates a piped writer that is not yet connected to a piped reader.
PipedWriter(PipedReader snk)It creates a piped writer connected to the specified piped reader.

Method

Modifier and TypeMethodMethod
voidclose()It closes this piped output stream and releases any system resources associated with this stream.
voidconnect(PipedReader snk)It connects this piped writer to a receiver.
voidflush()It flushes this output stream and forces any buffered output characters to be written out.
voidwrite(char[] cbuf, int off, int len)It writes len characters from the specified character array starting at offset off to this piped output stream.
voidwrite(int c)It writes the specified char to the piped output stream.

Example

Output:

I love my country





Latest Courses