Class ForwardSeekableStream
java.lang.Object
java.io.InputStream
org.apache.xmlgraphics.image.codec.util.SeekableStream
org.apache.xmlgraphics.image.codec.util.ForwardSeekableStream
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
A subclass of
SeekableStream that may be used
to wrap a regular InputStream efficiently.
Seeking backwards is not supported.-
Field Summary
Fields inherited from class org.apache.xmlgraphics.image.codec.util.SeekableStream
markPos -
Constructor Summary
ConstructorsConstructorDescriptionConstructs aInputStreamForwardSeekableStreamfrom a regularInputStream. -
Method Summary
Modifier and TypeMethodDescriptionfinal intForwards the request to the realInputStream.final booleanReturnsfalsesince seking backwards is not supported.final voidclose()Forwards the request to the realInputStream.final longReturns the current position in the stream (bytes read).final voidmark(int readLimit) Forwards the request to the realInputStream.booleanForwards the request to the realInputStream.final intread()Forwards the request to the realInputStream.final intread(byte[] b, int off, int len) Forwards the request to the realInputStream.final voidreset()Forwards the request to the realInputStream.final voidseek(long pos) Seeks forward to the given position in the stream.final longskip(long n) Forwards the request to the realInputStream.Methods inherited from class org.apache.xmlgraphics.image.codec.util.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, wrapInputStreamMethods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ForwardSeekableStream
Constructs aInputStreamForwardSeekableStreamfrom a regularInputStream.
-
-
Method Details
-
read
Forwards 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:
IOException- if an I/O error occurs.
-
read
Forwards 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:
IOException- if an I/O error occurs.
-
skip
Forwards the request to the realInputStream.- Overrides:
skipin classInputStream- Throws:
IOException
-
available
Forwards the request to the realInputStream.- Overrides:
availablein classInputStream- Throws:
IOException
-
close
Forwards the request to the realInputStream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
mark
public final void mark(int readLimit) Forwards the request to the realInputStream. We useSeekableStream.markPos- Overrides:
markin classSeekableStream
-
reset
Forwards the request to the realInputStream. We useSeekableStream.markPos- Overrides:
resetin classSeekableStream- Throws:
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
Seeks 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:
IOException- ifposis less than0or if an I/O error occurs.
-