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 aInputStreamForwardSeekableStream
from a regularInputStream
. -
Method Summary
Modifier and Type Method Description int
available()
Forwards the request to the realInputStream
.boolean
canSeekBackwards()
Returnsfalse
since seking backwards is not supported.void
close()
Forwards the request to the realInputStream
.long
getFilePointer()
Returns the current position in the stream (bytes read).void
mark(int readLimit)
Forwards the request to the realInputStream
.boolean
markSupported()
Forwards the request to the realInputStream
.int
read()
Forwards the request to the realInputStream
.int
read(byte[] b, int off, int len)
Forwards the request to the realInputStream
.void
reset()
Forwards the request to the realInputStream
.void
seek(long pos)
Seeks forward to the given position in the stream.long
skip(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 aInputStreamForwardSeekableStream
from a regularInputStream
.
-
-
Method Details
-
read
public final int read() throws java.io.IOExceptionForwards the request to the realInputStream
.- Specified by:
read
in classSeekableStream
- Returns:
- the next byte of data, or
-1
if 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:
read
in classSeekableStream
- Parameters:
b
- the buffer into which the data is read.off
- the start offset in arrayb
at which the data is written.len
- the maximum number of bytes to read.- Returns:
- the total number of bytes read into the buffer, or
-1
if 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:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
available
public final int available() throws java.io.IOExceptionForwards the request to the realInputStream
.- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public final void close() throws java.io.IOExceptionForwards the request to the realInputStream
.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
mark
public final void mark(int readLimit)Forwards the request to the realInputStream
.- Overrides:
mark
in classSeekableStream
-
reset
public final void reset() throws java.io.IOExceptionForwards the request to the realInputStream
.- Overrides:
reset
in classSeekableStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()Forwards the request to the realInputStream
.- Overrides:
markSupported
in classSeekableStream
-
canSeekBackwards
public final boolean canSeekBackwards()Returnsfalse
since seking backwards is not supported.- Overrides:
canSeekBackwards
in classSeekableStream
-
getFilePointer
public final long getFilePointer()Returns the current position in the stream (bytes read).- Specified by:
getFilePointer
in 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. Ifpos
is smaller than the current position as returned bygetFilePointer()
, nothing happens.- Specified by:
seek
in 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
- ifpos
is less than0
or if an I/O error occurs.
-