Android
java.io
public class

java.io.PipedWriter

java.lang.Object
java.io.Writer Closeable Flushable Appendable
java.io.PipedWriter

PipedWriter is a class which places 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.

See Also

Summary

Fields inherited from class java.io.Writer

Public Constructors

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

Public Methods

          void  close()
Close this PipedWriter.
          void  connect(PipedReader stream)
Connects this PipedWriter to a PipedReader.
          void  flush()
Notifies the readers on the PipedReader that characters can be read.
          void  write(char[] buffer, int offset, int count)
Writes count chars from the char array buffer starting at offset index to this PipedWriter.
          void  write(int c)
Writes the character c to this PipedWriter.
Methods inherited from class java.io.Writer
Methods inherited from class java.lang.Object
Methods inherited from interface java.io.Closeable
Methods inherited from interface java.io.Flushable
Methods inherited from interface java.lang.Appendable

Details

Public Constructors

public PipedWriter()

Constructs a new unconnected PipedWriter. The resulting Stream must be connected to a PipedReader before data may be written to it.

public PipedWriter(PipedReader dest)

Constructs a new PipedWriter connected to the PipedReader dest. Any data written to this Writer can be read from the dest.

Parameters

dest the PipedReader to connect to.

Throws

IOException if dest is already connected.

Public Methods

public void close()

Close this PipedWriter. Any data buffered in the corresponding PipedReader can be read, then -1 will be returned to the reader. If this Writer is not connected, this method does nothing.

Throws

IOException If an error occurs attempting to close this PipedWriter.

public void connect(PipedReader stream)

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

Parameters

stream the destination PipedReader.

Throws

IOException If this Writer or the dest is already connected.

public void flush()

Notifies the readers on the PipedReader that characters can be read. This method does nothing if this Writer is not connected.

Throws

IOException If an IO error occurs during the flush.

public void write(char[] buffer, int offset, int count)

Writes count chars from the char array buffer starting at offset index to this PipedWriter. The written data can now be read from the destination PipedReader. 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 input or output pipe.

Parameters

buffer the buffer to be written
offset offset in buffer to get chars
count number of chars in buffer to write

Throws

IOException If the receiving thread was terminated without closing the pipe. This case is not currently handled correctly.
InterruptedIOException If the pipe is full and the current thread is interrupted waiting for space to write data. This case is not currently handled correctly.
NullPointerException If the receiver has not been connected yet.
IllegalArgumentException If any of the arguments are out of bounds.

public void write(int c)

Writes the character c to this PipedWriter. The written data can now be read from the destination PipedReader. 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 input or output pipe.

Parameters

c the character to be written

Throws

IOException If the receiving thread was terminated without closing the pipe. This case is not currently handled correctly.
InterruptedIOException If the pipe is full and the current thread is interrupted waiting for space to write data. This case is not currently handled correctly.
NullPointerException If the receiver has not been connected yet.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48