|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
java.io.PipedInputStream
public class PipedInputStream
PipedInputStream is a class which receives information on a communications pipe. When two threads want to pass data back and forth, one creates a piped output stream and the other creates a piped input stream.
PipedOutputStream| Field Summary | |
|---|---|
protected byte[] |
buffer
The circular buffer through which data is passed. |
protected int |
in
The index in buffer where the next byte will be written. |
(package private) boolean |
isConnected
Indicates if this pipe is connected |
protected int |
out
The index in buffer where the next byte will be read. |
protected static int |
PIPE_SIZE
The size of the default pipe in bytes |
| Constructor Summary | |
|---|---|
PipedInputStream()
Constructs a new unconnected PipedInputStream. |
|
PipedInputStream(PipedOutputStream out)
Constructs a new PipedInputStream connected to the PipedOutputStream out. |
|
| Method Summary | |
|---|---|
int |
available()
Returns a int representing the number of bytes that are available before this PipedInputStream will block. |
void |
close()
Close this PipedInputStream. |
void |
connect(PipedOutputStream src)
Connects this PipedInputStream to a PipedOutputStream. |
(package private) void |
done()
|
int |
read()
Reads a single byte from this PipedInputStream and returns the result as an int. |
int |
read(byte[] bytes,
int offset,
int count)
Reads at most count bytes from this PipedInputStream and
stores them in byte array buffer starting at
offset. |
protected void |
receive(int oneByte)
Receives a byte and stores it into the PipedInputStream. |
| 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 |
| Field Detail |
|---|
protected byte[] buffer
protected int in
buffer where the next byte will be written.
protected int out
buffer where the next byte will be read.
protected static final int PIPE_SIZE
boolean isConnected
| Constructor Detail |
|---|
public PipedInputStream()
public PipedInputStream(PipedOutputStream out)
throws IOException
out. Any data written to the output stream can be read
from the this input stream.
out - the PipedOutputStream to connect to.
IOException - if this or out are already connected.| Method Detail |
|---|
public int available()
throws IOException
available in class InputStreamIOException - If an error occurs in this stream.
public void close()
throws IOException
close in interface Closeableclose in class InputStreamIOException - If an error occurs attempting to close this stream.
public void connect(PipedOutputStream src)
throws IOException
src - the source PipedOutputStream.
IOException - If either stream is already connected.
public int read()
throws IOException
read in class InputStreamIOException - If the stream is already closed or another IOException
occurs.
public int read(byte[] bytes,
int offset,
int count)
throws IOException
count bytes from this PipedInputStream and
stores them in byte array buffer starting at
offset. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered. Separate threads
should be used for the reader of the PipedInputStream and the
PipedOutputStream. There may be undesirable results if more than one
Thread interacts a input or output pipe.
read in class InputStreambytes - the byte array in which to store the read bytes.offset - the offset in buffer to store the read bytes.count - the maximum number of bytes to store in buffer.
IOException - If the stream is already closed or another IOException
occurs.
protected void receive(int oneByte)
throws IOException
in in the buffer.
If the buffer is full and the thread sending #receive is interrupted, the InterruptedIOException will be thrown.
oneByte - the byte to store into the pipe.
IOException - If the stream is already closed or another IOException
occurs.void done()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||