Package pixy.io
Class ForwardSeekableStream
java.lang.Object
java.io.InputStream
pixy.io.SeekableStream
pixy.io.ForwardSeekableStream
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable
public class ForwardSeekableStream extends SeekableStream
A subclass of
SeekableStream that may be used
to wrap a regular InputStream efficiently.
Seeking backwards is not supported.
This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.
-
Constructor Summary
Constructors Constructor Description ForwardSeekableStream(java.io.InputStream src)Constructs aInputStreamForwardSeekableStreamfrom a regularInputStream. -
Method Summary
Modifier and Type Method Description intavailable()Forwards the request to the realInputStream.booleancanSeekBackwards()Returnsfalsesince seking backwards is not supported.voidclose()Forwards the request to the realInputStream.longgetFilePointer()Returns the current position in the stream (bytes read).voidmark(int readLimit)Forwards the request to the realInputStream.booleanmarkSupported()Forwards the request to the realInputStream.intread()Forwards the request to the realInputStream.intread(byte[] b, int off, int len)Forwards the request to the realInputStream.voidreset()Forwards the request to the realInputStream.voidseek(long pos)Seeks forward to the given position in the stream.longskip(long n)Forwards the request to the realInputStream.Methods inherited from class pixy.io.SeekableStream
finalize, readBoolean, readByte, readChar, readCharLE, readDouble, readDoubleLE, readFloat, readFloatLE, readFully, readFully, readInt, readIntLE, readLine, readLong, readLongLE, readShort, readShortLE, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedShort, readUnsignedShortLE, readUTF, skipBytes, wrapInputStream
-
Constructor Details
-
ForwardSeekableStream
public ForwardSeekableStream(java.io.InputStream src)Constructs aInputStreamForwardSeekableStreamfrom a regularInputStream.
-
-
Method Details
-
read
public final int read() throws java.io.IOExceptionForwards the request to the realInputStream.- Specified by:
readin classSeekableStream- Returns:
- the next byte of data, or
-1if the end of the stream is reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
read
public final int read(byte[] b, int off, int len) throws java.io.IOExceptionForwards the request to the realInputStream.- Specified by:
readin classSeekableStream- Parameters:
b- the buffer into which the data is read.off- the start offset in arraybat which the data is written.len- the maximum number of bytes to read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
skip
public final long skip(long n) throws java.io.IOExceptionForwards the request to the realInputStream.- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public final int available() throws java.io.IOExceptionForwards the request to the realInputStream.- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public final void close() throws java.io.IOExceptionForwards the request to the realInputStream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
mark
public final void mark(int readLimit)Forwards the request to the realInputStream.- Overrides:
markin classSeekableStream
-
reset
public final void reset() throws java.io.IOExceptionForwards the request to the realInputStream.- Overrides:
resetin classSeekableStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()Forwards the request to the realInputStream.- Overrides:
markSupportedin classSeekableStream
-
canSeekBackwards
public final boolean canSeekBackwards()Returnsfalsesince seking backwards is not supported.- Overrides:
canSeekBackwardsin classSeekableStream
-
getFilePointer
public final long getFilePointer()Returns the current position in the stream (bytes read).- Specified by:
getFilePointerin classSeekableStream- Returns:
- the offset from the beginning of the stream, in bytes, at which the next read occurs.
-
seek
public final void seek(long pos) throws java.io.IOExceptionSeeks forward to the given position in the stream. Ifposis smaller than the current position as returned bygetFilePointer(), nothing happens.- Specified by:
seekin classSeekableStream- 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.
-