|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.io.InputStream
ice.util.io.LazyCachedInputStream
A LazyCachedInputStream adds functionality to another input
stream, namely the ability to lazily cache the input. As bytes from the
underlying stream are read, the internal byte cache is filled as
necessary.
By using the methods ,
read(int) and
read(int, byte[]) one could even have a
custom read(int, byte[], int, int)InputStream that uses a
LazyCachedInputStream as underlying InputStream and
administers its own position. In this way you could have more than one client
of a LazyCachedInputStream and every client can read all the
data from start to finish.
| Constructor Summary | |
LazyCachedInputStream(InputStream inputStream)
Creates a LazyCachedInputStream and saves its argument,
the specified inputStream |
|
LazyCachedInputStream(InputStream inputStream,
int initialCacheSize)
Creates a LazyCachedInputStream and saves its argument,
the specified inputStream |
|
| Method Summary | |
int |
available()
|
void |
close()
|
int |
read()
|
int |
read(byte[] bytes)
|
int |
read(byte[] bytes,
int offset,
int length)
|
int |
read(int position)
Reads the next byte of data from the input stream from the specified position. |
int |
read(int position,
byte[] bytes)
Reads some number of bytes from the input stream from the specified position and stores them into the specified buffer array
bytes. |
int |
read(int position,
byte[] bytes,
int offset,
int length)
Reads up to the specified length bytes of data from the
input stream from the specified position into the specified
array bytes at the specified offset. |
| Methods inherited from class java.io.InputStream |
mark, markSupported, reset, skip |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public LazyCachedInputStream(InputStream inputStream)
throws IllegalArgumentException
Creates a LazyCachedInputStream and saves its argument,
the specified inputStream, for later use.
inputStream - the underlying input stream.
IllegalArgumentException - if the specified inputStream is
null.
public LazyCachedInputStream(InputStream inputStream,
int initialCacheSize)
throws IllegalArgumentException
Creates a LazyCachedInputStream and saves its argument,
the specified inputStream, for later use. An internal byte
cache of initialCacheSize is created.
inputStream - the underlying input stream.initialCacheSize - the initial cache size.
IllegalArgumentException - if one of the following occurs:
inputStream is
null orinitialCacheSize is
less than 0.| Method Detail |
public int available()
throws IOException
IOException
public void close()
throws IOException
IOException
public int read()
throws IOException
IOException
public int read(byte[] bytes)
throws IOException
IOException
public int read(byte[] bytes,
int offset,
int length)
throws IOException
IOException
public int read(int position)
throws IndexOutOfBoundsException,
IOException
Reads the next byte of data from the input stream from the specified
position.
position - the position to start reading from.
-1 if the end of the
stream is reached.
IndexOutOfBoundsException - if the specified position is less than
0.
IOException - if an I/O error occurs.read()
public int read(int position,
byte[] bytes)
throws IllegalArgumentException,
IndexOutOfBoundsException,
IOException
Reads some number of bytes from the input stream from the specified
position and stores them into the specified buffer array
bytes.
position - the position to start reading from.bytes - the buffer into which the data is read.
-1 if there is no more data because the end of
the stream has been reached.
IllegalArgumentException - if the specified bytes is null.
IndexOutOfBoundsException - if the specified position is less than
0.
IOException - if an I/O error occurs.read(byte[]),
read(int, byte[], int, int)
public int read(int position,
byte[] bytes,
int offset,
int length)
throws IllegalArgumentException,
IndexOutOfBoundsException,
IOException
Reads up to the specified length bytes of data from the
input stream from the specified position into the specified
array bytes at the specified offset.
position - the position to start reading from.bytes - the buffer into which the data is read.offset - the start offset in array bytes at which the
data is written.length - the maximum number of bytes to read.
-1 if there is no more data because the end of
the stream has been reached.
IllegalArgumentException - if the specified bytes is null.
IndexOutOfBoundsException - if one of the following occurs:
position is less than
0,offset is either less
than 0 or greater than
bytes.length,length is less than
0 oroffset + length is either less
than 0 or greater than
bytes.length.IOException - if an I/O error occurs.read(byte[], int, int)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||