Package com.twelvemonkeys.imageio.util
Class IIOInputStreamAdapter
java.lang.Object
java.io.InputStream
com.twelvemonkeys.imageio.util.IIOInputStreamAdapter
- All Implemented Interfaces:
Closeable
,AutoCloseable
IIOInputStreamAdapter
Note: You should always wrap this stream in a BufferedInputStream
.
If not, performance may degrade significantly.
- Version:
- $Id: IIOInputStreamAdapter.java,v 1.0 Sep 26, 2007 11:35:59 AM haraldk Exp$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private ImageInputStream
private long
private long
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates anInputStream
that reads from the givenImageInputStream
.IIOInputStreamAdapter
(ImageInputStream pInput, long pLength) Creates anInputStream
that reads from the givenImageInputStream
.private
IIOInputStreamAdapter
(ImageInputStream pInput, long pLength, boolean pHasLength) -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
Marks this stream as closed.private long
findMaxLen
(long pLength) Finds the maximum number of bytes we can read or skip, from this stream.void
mark
(int pReadLimit) boolean
int
read()
final int
read
(byte[] pBytes) int
read
(byte[] pBytes, int pOffset, int pLength) void
reset()
long
skip
(long pLength) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
input
-
hasLength
private final boolean hasLength -
left
private long left -
markPosition
private long markPosition
-
-
Constructor Details
-
IIOInputStreamAdapter
Creates anInputStream
that reads from the givenImageInputStream
. The input stream will read from the current stream position, until the end of the underlying stream.- Parameters:
pInput
- theImageInputStream
to read from.
-
IIOInputStreamAdapter
Creates anInputStream
that reads from the givenImageInputStream
. The input stream will read from the current stream position, until at mostpLength
bytes has been read.- Parameters:
pInput
- theImageInputStream
to read from.pLength
- the length of the stream
-
IIOInputStreamAdapter
-
-
Method Details
-
close
Marks this stream as closed. This implementation does not close the underlying stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
mark
public void mark(int pReadLimit) - Overrides:
mark
in classInputStream
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
findMaxLen
private long findMaxLen(long pLength) Finds the maximum number of bytes we can read or skip, from this stream. The number will be in the range[0 ... bytes left]
.- Parameters:
pLength
- the requested length- Returns:
- the maximum number of bytes to read
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-