Android
java.io
public class

java.io.PipedReader

java.lang.Object
java.io.Reader Closeable Readable
java.io.PipedReader

PipedReader is a class which receives information on a communications pipe. When two threads want to pass data back and forth, one creates a piped writer and the other creates a piped reader.

Summary

Fields inherited from class java.io.Reader

Public Constructors

            PipedReader()
Constructs a new unconnected PipedReader.
            PipedReader(PipedWriter out)
Constructs a new PipedReader connected to the PipedWriter out.

Public Methods

          void  close()
Close this PipedReader.
          void  connect(PipedWriter src)
Connects this PipedReader to a PipedWriter.
          int  read(char[] buffer, int offset, int count)
Reads at most count character from this PipedReader and stores them in char array buffer starting at offset.
          int  read()
Reads the next character from this Reader.
          boolean  ready()
Answer a boolean indicating whether or not this Reader is ready to be read.
Methods inherited from class java.io.Reader
Methods inherited from class java.lang.Object
Methods inherited from interface java.io.Closeable
Methods inherited from interface java.lang.Readable

Details

Public Constructors

public PipedReader()

Constructs a new unconnected PipedReader. The resulting Reader must be connected to a PipedWriter before data may be read from it.

public PipedReader(PipedWriter out)

Constructs a new PipedReader connected to the PipedWriter out. Any data written to the writer can be read from the this reader.

Parameters

out the PipedWriter to connect to.

Throws

IOException if this or out are already connected.

Public Methods

public void close()

Close this PipedReader. This implementation releases the buffer used for the pipe and notifies all threads waiting to read or write.

Throws

IOException If an error occurs attempting to close this reader.

public void connect(PipedWriter src)

Connects this PipedReader to a PipedWriter. Any data written to the Writer becomes available in this Reader.

Parameters

src the source PipedWriter.

Throws

IOException If either Writer or Reader is already connected.

public int read(char[] buffer, int offset, int count)

Reads at most count character from this PipedReader and stores them in char array buffer starting at offset. Answer the number of characters actually read or -1 if no characters were read and end of stream was encountered. Separate threads should be used for the reader of the PipedReader and the PipedWriter. There may be undesirable results if more than one Thread interacts a reader or writer pipe.

Parameters

buffer the character array in which to store the read characters.
offset the offset in buffer to store the read characters.
count the maximum number of characters to store in buffer.

Returns

  • int the number of characters actually read or -1 if end of reader.

Throws

IOException If the reader is already closed or another IOException occurs.

public int read()

Reads the next character from this Reader. Answer the character actually read or -1 if no character was read and end of reader was encountered. Separate threads should be used for the reader of the PipedReader and the PipedWriter. There may be undesirable results if more than one Thread interacts a reader or writer pipe.

Returns

  • int the character read -1 if end of reader.

Throws

IOException If the reader is already closed or another IOException occurs.

public boolean ready()

Answer a boolean indicating whether or not this Reader is ready to be read. Returns true if the buffer contains characters to be read.

Returns

  • boolean true if there are characters ready, false otherwise.

Throws

IOException If the reader is already closed or another IOException occurs.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48