|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
jsync.JoinInputStream
Class multiplexing input from several streams. This class merge several input streams into single input stream. Size of input buffer determines maximal amount of data, which can be read from one stream without interleaving with data from other streams.
Field Summary | |
static int |
defaultBufferSize
Default size of read buffer. |
Constructor Summary | |
JoinInputStream(java.io.InputStream[] streams,
int bufferSize)
Create stream joining streams specified in the array. |
|
JoinInputStream(java.io.InputStream one,
java.io.InputStream two)
Create stream joining two specified streams. |
|
JoinInputStream(java.io.InputStream one,
java.io.InputStream two,
int bufferSize)
Create stream joining two specified streams. |
Method Summary | |
void |
close()
Close all attached input streams and stop their listener threads. |
int |
getStreamIndex()
Get index of thread from which data was retrieved in last read operation. |
int |
read()
Reads the next byte of data from one of input streams. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from one of input streams
into an array of bytes. |
Methods inherited from class java.io.InputStream |
available, mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int defaultBufferSize
Constructor Detail |
public JoinInputStream(java.io.InputStream[] streams, int bufferSize)
streams
- array with input streams which should be joinedbufferSize
- specifies size of read bufferpublic JoinInputStream(java.io.InputStream one, java.io.InputStream two, int bufferSize)
one
- first input stream to be mergedtwo
- second input stream to be mergedbufferSize
- specifies size of read bufferpublic JoinInputStream(java.io.InputStream one, java.io.InputStream two)
one
- first input stream to be mergedtwo
- second input stream to be mergedMethod Detail |
public int read() throws java.io.IOException
int
in the range
0
to 255
. If no byte is available
because the 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 catched.
-1
if the end of the
stream is reached.
java.io.IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len) throws java.io.IOException
len
bytes of data from one of input streams
into an array of bytes. This method blocks until some input is
available. If the first argument is null,
up to
len
bytes are read and discarded.
The read
method of InputStream
reads a
single byte at a time using the read method of zero arguments to
fill in the array. Subclasses are encouraged to provide a more
efficient implementation of this method.
b
- the buffer into which the data is read.off
- the start offset of the data.len
- the maximum number of bytes read.
-1
if there is no more data because the end of
the stream has been reached.
java.io.IOException
- if an I/O error occurs.public void close() throws java.io.IOException
java.io.IOException
public final int getStreamIndex()
read
operation. Indices are started from 0.
read
operation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |