Class java.io.PipedInputStream
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.io.PipedInputStream

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

public class PipedInputStream
extends InputStream
A piped input stream is the receiving end of a communications pipe. Two threads can communicate by having one thread send data through a piped output stream and having the other thread read the data through a piped input stream.

Version:
1.19, 07/01/98
Author:
James Gosling
Since:
JDK1.0
See Also:
PipedOutputStream

Variable Index

 o PIPE_SIZE
 o buffer
The circular buffer into which incoming data is placed.
 o in
 o out

Constructor Index

 o java.io.PipedInputStream(PipedOutputStream)
Creates a piped input stream connected to the specified piped output stream.
 o java.io.PipedInputStream()
Creates a piped input stream that is not yet connected to a piped output stream.

Method Index

 o available()
Returns the number of bytes that can be read from this input stream without blocking.
 o close()
Closes this piped input stream and releases any system resources associated with the stream.
 o connect(PipedOutputStream)
Connects this piped input stream to a sender.
 o read()
Reads the next byte of data from this piped input stream.
 o read(byte[], int, int)
Reads up to len bytes of data from this piped input stream into an array of bytes.
 o receive(int)
Receives a byte of data.

Variables

 o PIPE_SIZE
protected static final int PIPE_SIZE

Since: JDK1.1
 o buffer
protected byte[] buffer
The circular buffer into which incoming data is placed.

Since: JDK1.1
 o in
protected int in

Since: JDK1.1
 o out
protected int out

Since: JDK1.1

Constructors

 o PipedInputStream
public PipedInputStream(PipedOutputStream src) throws IOException
Creates a piped input stream connected to the specified piped output stream.

Parameters:
src - the stream to connect to.
Throws: IOException
if an I/O error occurs.
Since:
JDK1.0
 o PipedInputStream
public PipedInputStream()
Creates a piped input stream that is not yet connected to a piped output stream. It must be connected to a piped output stream, either by the receiver or the sender, before being used.

Since:
JDK1.0
See Also:
connect(java.io.PipedOutputStream), connect(java.io.PipedInputStream)

Methods

 o available
public synchronized int available() throws IOException
Returns the number of bytes that can be read from this input stream without blocking. This method overrides the available method of the parent class.

Returns:
the number of bytes that can be read from this input stream without blocking.
Throws: IOException
if an I/O error occurs.
Overrides:
available in class InputStream
Since:
JDK1.0.2
 o close
public void close() throws IOException
Closes this piped input stream and releases any system resources associated with the stream.

Throws: IOException
if an I/O error occurs.
Overrides:
close in class InputStream
Since:
JDK1.0
 o connect
public void connect(PipedOutputStream src) throws IOException
Connects this piped input stream to a sender.

Parameters:
src - The piped output stream to connect to.
Throws: IOException
if an I/O error occurs.
Since:
JDK1.0
 o read
public synchronized int read() throws IOException
Reads the next byte of data from this piped input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because this end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws: IOException
if the pipe is broken.
Overrides:
read in class InputStream
Since:
JDK1.0
 o read
public synchronized int read(byte b,
                             int off,
                             int len) throws IOException
Reads up to len bytes of data from this piped input stream into an array of bytes. This method blocks until at least one byte of 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 total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws: IOException
if an I/O error occurs.
Overrides:
read in class InputStream
Since:
JDK1.0
 o 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.
Since:
JDK1.1

All Packages  Class Hierarchy  This Package  Previous  Next  Index