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.InputStreamIIOInputStreamAdapterNote: 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 booleanhasLengthprivate javax.imageio.stream.ImageInputStreaminputprivate longleftprivate longmarkPosition
-
Constructor Summary
Constructors Modifier Constructor Description IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput)Creates anInputStreamthat reads from the givenImageInputStream.IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput, long pLength)Creates anInputStreamthat reads from the givenImageInputStream.privateIIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput, long pLength, boolean pHasLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()Marks this stream as closed.private longfindMaxLen(long pLength)Finds the maximum number of bytes we can read or skip, from this stream.voidmark(int pReadLimit)booleanmarkSupported()intread()intread(byte[] pBytes)intread(byte[] pBytes, int pOffset, int pLength)voidreset()longskip(long pLength)
-
-
-
Constructor Detail
-
IIOInputStreamAdapter
public IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput)
Creates anInputStreamthat reads from the givenImageInputStream. The input stream will read from the current stream position, until the end of the underlying stream.- Parameters:
pInput- theImageInputStreamto read from.
-
IIOInputStreamAdapter
public IIOInputStreamAdapter(javax.imageio.stream.ImageInputStream pInput, long pLength)Creates anInputStreamthat reads from the givenImageInputStream. The input stream will read from the current stream position, until at mostpLengthbytes has been read.- Parameters:
pInput- theImageInputStreamto 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.IOExceptionMarks this stream as closed. This implementation does not close the underlying stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
mark
public void mark(int pReadLimit)
- Overrides:
markin classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public final int read(byte[] pBytes) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] pBytes, int pOffset, int pLength) throws java.io.IOException- Overrides:
readin 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:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
-