Class SubStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.twelvemonkeys.io.SubStream
- All Implemented Interfaces:
Closeable, AutoCloseable
An
InputStream reading up to a specified number of bytes from an
underlying stream.-
Field Summary
FieldsFields inherited from class FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionSubStream(InputStream stream, long length) Creates aSubStreamof the givenstream. -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()Marks this stream as closed.private longfindMaxLen(long length) Finds the maximum number of bytes we can read or skip, from this stream.voidmark(int readLimit) intread()intread(byte[] bytes) intread(byte[] bytes, int off, int len) voidreset()longskip(long length) Methods inherited from class FilterInputStream
markSupportedMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
bytesLeft
private long bytesLeft -
markLimit
private int markLimit
-
-
Constructor Details
-
SubStream
Creates aSubStreamof the givenstream.- Parameters:
stream- the underlying input streamlength- maximum number of bytes to read from this stream
-
-
Method Details
-
close
Marks this stream as closed. This implementation does not close the underlying stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
available
- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
mark
public void mark(int readLimit) - Overrides:
markin classFilterInputStream
-
reset
- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
findMaxLen
private long findMaxLen(long length) Finds the maximum number of bytes we can read or skip, from this stream.- Parameters:
length- the requested length- Returns:
- the maximum number of bytes to read
-