java.io
Class PipedInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.PipedInputStream

public class PipedInputStream
extends InputStream

PipedInputStream must be connected to a PipedOutputStream to be useful. A thread reading from a PipedInputStream recieves data from a thread writing to the PipedOutputStream it is connected to.

See Also:
PipedOutputStream

Constructor Summary
PipedInputStream()
          Creates an input file that isn't connected to anything (yet).
PipedInputStream(PipedOutputStream src)
          Creates an input file from the specified PiledOutputStream.
 
Method Summary
 int available()
          Returns the number of bytes that can be read without blocking.
 void close()
          Closes the input stream.
 void connect(PipedOutputStream src)
          Connects this input stream to a sender.
 int read()
          Reads a byte of data.
 int read(byte[] b, int off, int len)
          Reads into an array of bytes.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PipedInputStream

public PipedInputStream(PipedOutputStream src)
                 throws IOException
Creates an input file from the specified PiledOutputStream.

Parameters:
src - the stream to connect to.

PipedInputStream

public PipedInputStream()
Creates an input file that isn't connected to anything (yet). It must be connected to a PipedOutputStream before being used.

Method Detail

connect

public void connect(PipedOutputStream src)
             throws IOException
Connects this input stream to a sender.

Parameters:
src - The OutputStream to connect to.
IOException

read

public int read()
         throws IOException
Reads a byte of data. This method will block if no input is available.

Specified by:
read in class InputStream
Returns:
the byte read, or -1 if the end of the stream is reached.
Throws:
IOException - If the pipe is broken.

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Reads into an array of bytes. Blocks until some input is available.

Overrides:
read in class InputStream
Parameters:
b - the buffer into which the data is read
off - the start offset of the data
len - the maximum number of bytes read
Returns:
the actual number of bytes read, -1 is returned when the end of the stream is reached.
Throws:
IOException - If an I/O error has occurred.

available

public int available()
              throws IOException
Description copied from class: InputStream
Returns the number of bytes that can be read without blocking.

Overrides:
available in class InputStream
Returns:
the number of available bytes.
IOException

close

public void close()
           throws IOException
Closes the input stream. Must be called to release any resources associated with the stream.

Overrides:
close in class InputStream
Throws:
IOException - If an I/O error has occurred.