org.entityfs.util.io
Class RangeInputStream
java.lang.Object
java.io.InputStream
org.entityfs.util.io.RangeInputStream
- All Implemented Interfaces:
- Closeable
public class RangeInputStream
- extends InputStream
This InputStream operates on a range of data in a
RandomAccess object. It starts to read data from the lower limit, and
continues until it reaches the upper limit.
- Since:
- 1.1
- Author:
- Karl Gustafsson
- See Also:
RangeRandomAccess
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RangeInputStream
public RangeInputStream(RandomAccess ra,
long lowerLimit,
long upperLimit)
throws IllegalArgumentException
- Create a new
RangeInputStream. The amount of data available in
the stream is upperLimit - lowerLimit + 1 bytes.
- Parameters:
ra - The RandomAccess to read data from. No other object
should manipulate this object while this object is active. The
RandomAccess is closed when this object is closed.lowerLimit - The start position in the RandomAccess where
this object starts to read data from.upperLimit - The upper limit. This object will read data until it
reaches the upper limit position.
- Throws:
IllegalArgumentException - If lowerLimit is less than zero,
if the upperLimit is less than the lowerLimit or if the
upper limit is beyond the end of the file.
read
public int read()
throws IOException
- Specified by:
read in class InputStream
- Throws:
IOException
read
public int read(byte[] barr)
throws IOException
- Overrides:
read in class InputStream
- Throws:
IOException
read
public int read(byte[] barr,
int offset,
int length)
throws IOException
- Overrides:
read in class InputStream
- Throws:
IOException
available
public int available()
throws IOException
- Overrides:
available in class InputStream
- Throws:
IOException
skip
public long skip(long n)
throws IOException
- Overrides:
skip in class InputStream
- Throws:
IOException
close
public void close()
throws IOException
- Specified by:
close in interface Closeable- Overrides:
close in class InputStream
- Throws:
IOException