ewe.io
Class PartialInputStream
java.lang.Object
ewe.util.Errorable
ewe.io.BasicStreamObject
ewe.io.StreamObject
ewe.io.StreamAdapter
ewe.io.PartialInputStream
- All Implemented Interfaces:
- BasicStream, BufferedStream, Stream, Streamable, StreamCanPause
- public class PartialInputStream
- extends StreamAdapter
This class is used to get a "sub-stream" of data from another Stream. The
partial stream can limit the amount of data which can be read from the original
Stream. Note the following:
Calling close() on a PartialInputStream does not close the original stream, unless closeUnderlying is true.
Setting a limit of -1 will not impose any limit on the number of bytes which
can be read.
Input begins at the current point in the source input stream.
|
Field Summary |
boolean |
closeUnderlying
If this is true, then a call to close() will close the underlying stream
as well. |
|
Method Summary |
boolean |
closeStream()
This will not close the underlying stream unless closeUnderlying is true. |
boolean |
isOpen()
Returns if the stream is open or not. |
int |
nonBlockingRead(byte[] buff,
int offset,
int count)
This calls the nonBlockingRead() of the client BasicStream. |
int |
nonBlockingWrite(byte[] buff,
int start,
int length)
This calls the nonBlockingWrite() of the client BasicStream. |
boolean |
pushback(byte[] bytes,
int start,
int count)
Push back some bytes into the input stream. |
| Methods inherited from class ewe.io.StreamObject |
close, doRead, doWrite, flush, nap, nap, read, readAByte, readBytes, readBytes, write, writeAByte, writeBytes, writeBytes |
| Methods inherited from interface ewe.io.Stream |
flush, read, read, read, readBytes, readBytes, toInputStream, toOutputStream, write, write, write, writeBytes, writeBytes |
closeUnderlying
public boolean closeUnderlying
- If this is true, then a call to close() will close the underlying stream
as well.
PartialInputStream
public PartialInputStream(BasicStream input)
- Creates a new PartialInputStream with no limit.
PartialInputStream
public PartialInputStream(BasicStream input,
int limit)
- Creates a new PartialInputStream with the specified limit. If the limit
is -1, then there will be no limit imposed
PartialInputStream
public PartialInputStream(RandomAccessStream raf,
int start,
int limit)
PartialInputStream
public PartialInputStream(BasicStream input,
long limit)
- Creates a new PartialInputStream with the specified limit. If the limit
is -1, then there will be no limit imposed
PartialInputStream
public PartialInputStream(RandomAccessStream raf,
long start,
long limit)
pushback
public boolean pushback(byte[] bytes,
int start,
int count)
- Description copied from class:
StreamAdapter
- Push back some bytes into the input stream. There is no limit on the
number of bytes which can be pushed back. This can be called multiple
times.
- Specified by:
pushback in interface BufferedStream- Overrides:
pushback in class StreamAdapter
nonBlockingWrite
public int nonBlockingWrite(byte[] buff,
int start,
int length)
- Description copied from class:
StreamAdapter
- This calls the nonBlockingWrite() of the client BasicStream.
- Specified by:
nonBlockingWrite in interface BasicStream- Overrides:
nonBlockingWrite in class StreamAdapter
nonBlockingRead
public int nonBlockingRead(byte[] buff,
int offset,
int count)
- Description copied from class:
StreamAdapter
- This calls the nonBlockingRead() of the client BasicStream.
- Specified by:
nonBlockingRead in interface BasicStream- Overrides:
nonBlockingRead in class StreamAdapter
closeStream
public boolean closeStream()
throws IOException
- This will not close the underlying stream unless closeUnderlying is true.
- Specified by:
closeStream in interface BasicStream- Overrides:
closeStream in class StreamAdapter
- Throws:
IOException
isOpen
public boolean isOpen()
- Description copied from interface:
BasicStream
- Returns if the stream is open or not.
- Specified by:
isOpen in interface BasicStream- Overrides:
isOpen in class StreamAdapter