Package com.twelvemonkeys.imageio.util
Class IIOInputStreamAdapter
- java.lang.Object
-
- java.io.InputStream
-
- com.twelvemonkeys.imageio.util.IIOInputStreamAdapter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class IIOInputStreamAdapter extends java.io.InputStream
IIOInputStreamAdapterNote: 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
Fields Modifier and Type Field Description private boolean
hasLength
private javax.imageio.stream.ImageInputStream
input
private long
left
private long
markPosition
-
Constructor Summary
Constructors Modifier Constructor Description IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput)
Creates anInputStream
that reads from the givenImageInputStream
.IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput, long pLength)
Creates anInputStream
that reads from the givenImageInputStream
.private
IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput, long pLength, boolean pHasLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
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
markSupported()
int
read()
int
read(byte[] pBytes)
int
read(byte[] pBytes, int pOffset, int pLength)
void
reset()
long
skip(long pLength)
-
-
-
Constructor Detail
-
IIOInputStreamAdapter
public IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput)
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
public IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput, long pLength)
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
private IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput, long pLength, boolean pHasLength)
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Marks this stream as closed. This implementation does not close the underlying stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
mark
public void mark(int pReadLimit)
- Overrides:
mark
in classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public final int read(byte[] pBytes) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] pBytes, int pOffset, int pLength) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.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
public long skip(long pLength) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
-