public class PartialInputStream extends InputStream
Modifier and Type | Field and Description |
---|---|
boolean |
closeUnderlying
If this is true, then a call to close() will close the underlying stream
as well - by default it is false.
|
Constructor and Description |
---|
PartialInputStream(InputStream input)
Creates a new PartialInputStream with no limit.
|
PartialInputStream(InputStream input,
long limit)
Creates a new PartialInputStream with the specified limit.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
This will not close the underlying stream unless closeUnderlying is true.
|
boolean |
isOpen() |
int |
read()
This method reads an unsigned byte from the input stream and returns it
as an int in the range of 0-255.
|
int |
read(byte[] buff,
int offset,
int count)
This method read bytes from a stream and stores them into a
caller supplied buffer.
|
available, finalize, hashCode, mark, markSupported, read, reset, skip
public boolean closeUnderlying
public PartialInputStream(InputStream input)
public PartialInputStream(InputStream input, long limit)
public int read(byte[] buff, int offset, int count) throws IOException
InputStream
off
into the buffer and attempts to read
len
bytes. This method can return before reading the
number of bytes requested. The actual number of bytes read is
returned as an int. A -1 is returned to indicate the end of the
stream.
This method will block until some data can be read.
This method operates by calling the single byte read()
method
in a loop until the desired number of bytes are read. The read loop
stops short if the end of the stream is encountered or if an IOException
is encountered on any read operation except the first. If the first
attempt to read a bytes fails, the IOException is allowed to propagate
upward. And subsequent IOException is caught and treated identically
to an end of stream condition. Subclasses can (and should if possible)
override this method to provide a more efficient implementation.
read
in class InputStream
buff
- The array into which the bytes read should be storedoffset
- The offset into the array to start storing bytescount
- The requested number of bytes to readIOException
- If an error occurs.public int read() throws IOException
InputStream
This method will block until the byte can be read.
read
in class InputStream
IOException
- If an error occurspublic void close() throws IOException
close
in class InputStream
IOException
- If an error occurs, which can only happen
in a subclasspublic boolean isOpen()