Package pixy.io
Class FileCacheRandomAccessInputStream
java.lang.Object
java.io.InputStream
pixy.io.RandomAccessInputStream
pixy.io.FileCacheRandomAccessInputStream
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable
public class FileCacheRandomAccessInputStream extends RandomAccessInputStream
Implements a file cached random access input stream to ease the
decoding of some types of images such as TIFF which may need random
access to the underlying stream.
Based on com.sun.media.jai.codec.FileCacheSeekableStream.
- Version:
- 1.0 02/09/2014
- Author:
- Wen Yu, yuwen_66@yahoo.com
-
Field Summary
-
Constructor Summary
Constructors Constructor Description FileCacheRandomAccessInputStream(java.io.InputStream stream)Constructs aMemoryCacheRandomAccessInputStreamthat takes its source data from a regularInputStream.FileCacheRandomAccessInputStream(java.io.InputStream src, int bufLen) -
Method Summary
Modifier and Type Method Description voidclose()Closes this stream and releases any system resources associated with the stream.longgetStreamPointer()Returns the current offset in this stream.intread()intread(byte[] b, int off, int len)voidseek(long pos)Sets the stream-pointer offset, measured from the beginning of this file, at which the next read occurs.voidshallowClose()Closes the RandomAccessInputStream and it's underlying streamMethods inherited from class pixy.io.RandomAccessInputStream
ensureOpen, finalize, getEndian, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readS15Fixed16Number, readShort, readU16Fixed16Number, readU8Fixed8Number, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, setReadStrategy, skipBytes
-
Constructor Details
-
FileCacheRandomAccessInputStream
public FileCacheRandomAccessInputStream(java.io.InputStream stream) throws java.io.IOExceptionConstructs aMemoryCacheRandomAccessInputStreamthat takes its source data from a regularInputStream. Seeking backwards is supported by means of an file cache.An
IOExceptionwill be thrown if the attempt to create the cache file fails for any reason.- Throws:
java.io.IOException
-
FileCacheRandomAccessInputStream
public FileCacheRandomAccessInputStream(java.io.InputStream src, int bufLen) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Details
-
getStreamPointer
public long getStreamPointer()Returns the current offset in this stream.- Specified by:
getStreamPointerin classRandomAccessInputStream- Returns:
- the offset from the beginning of the stream, in bytes, at which the next read occurs.
-
seek
public void seek(long pos) throws java.io.IOExceptionSets the stream-pointer offset, measured from the beginning of this file, at which the next read occurs.- Specified by:
seekin classRandomAccessInputStream- Parameters:
pos- the offset position, measured in bytes from the beginning of the stream, at which to set the stream pointer.- Throws:
java.io.IOException- ifposis less than0or if an I/O error occurs.
-
read
public int read() throws java.io.IOException- Specified by:
readin classRandomAccessInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readin classRandomAccessInputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses this stream and releases any system resources associated with the stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
shallowClose
public void shallowClose() throws java.io.IOExceptionDescription copied from class:RandomAccessInputStreamCloses the RandomAccessInputStream and it's underlying stream- Specified by:
shallowClosein classRandomAccessInputStream- Throws:
java.io.IOException
-