PipedReader class

 

see also  pipes,  Reader class,  PipedWriter class

 

see Reader class for PipedReader's methods. They are:

 

.mark( readAheadLimit )  Mark the present position in the stream.

.markSupported( ) Tell whether this stream supports the mark(...) operation.

.read( )  Read a single character, returning it in the low end two bytes of an int.

.read( char[ ] )  Read characters into a char array.

.read( char[ ], offset, len)  Read characters into a portion of a char array.

.ready( ) Tell whether this stream is ready to be read.

.reset( )  Reset the stream.

.skip( n )  Skip over n characters in the stream.

.close( ) Close the stream.

 

plus

 

.connect(...)   below

 

 

  PipedReader provides a character input stream whose input source is a PipedWriter output stream to which it is always connected. This pairing is useful for communicating between two threads.

 

  PipedReader has implementations of all the methods from Reader.   see  Reader  for PipedReader's methods.

 

  Its source for input is always a PipedWriter stream.

 

  It adds one method of its own: 

 

 

void .connect( PipedWriter ) method  

 

This method causes this PipedReader to be connected to the piped writer source of its data. 

 

.pr.connect( pw );             achieves the same connection result as using a PipedReader

                                    constructor to make the connection to the PipedWiter. i.e. 

 

PipedReader pr = new PipedReader( pw );

 

  You cannot write with a PipedWriter until a PipedReader is connected to it.

 

  PipedReader supports mark(...) and reset( ).

 

  See the the pipes topic for more code examples illustrating the use of PipedReader.