    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class java.io.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

##

buffer
in
out
PIPE_SIZE

##

PipedInputStream()
  Creates an input file that isn't connected to anything (yet).
PipedInputStream(PipedOutputStream)
  Creates an input file from the specified PipedOutputStream.

##

available()
  Returns the number of bytes that can be read without blocking.
close()
  Closes the input stream.
connect(PipedOutputStream)
  Connects this input stream to a sender.
read()
  Reads a byte of data.
read(byte[], int, int)
  Reads into an array of bytes.
receive(int)
  Receives a byte of data.

##

PIPE_SIZE

      protected final static int PIPE_SIZE

buffer

      protected byte buffer[]

in

      protected int in

out

      protected int out

##

PipedInputStream

      public PipedInputStream(PipedOutputStream src) throws IOException

  Creates an input file from the specified PipedOutputStream.

  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.

##

connect

      public void connect(PipedOutputStream src) throws IOException

  Connects this input stream to a sender.

  Parameters:
    src - The OutputStream to connect to.

receive

      protected synchronized void receive(int b) throws IOException

  Receives a byte of data. This method will block if no input is available.

  Parameters:
    b - the byte being received
  Throws: IOException
    If the pipe is broken.

read

      public synchronized int read() throws IOException

  Reads a byte of data. This method will block if no input is available.

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

read

      public synchronized int read(byte b[],
                                   int off,
                                   int len) throws IOException

  Reads into an array of bytes. Blocks until some input is available.

  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.
  Overrides:
    read in class InputStream

available

      public synchronized int available() throws IOException

  Returns the number of bytes that can be read without blocking.

  Overrides:
    available in class InputStream

close

      public void close() throws IOException

  Closes the input stream. Must be called to release any resources associated with the stream.

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

    All Packages  Class Hierarchy  This Package  Previous  Next  Index