Package org.tukaani.xz
Class SeekableInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.tukaani.xz.SeekableInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
SeekableFileInputStream,SeekableXZInputStream
public abstract class SeekableInputStream extends java.io.InputStreamInput stream with random access support.
-
-
Constructor Summary
Constructors Constructor Description SeekableInputStream()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract longlength()Gets the size of the stream.abstract longposition()Gets the current position in the stream.abstract voidseek(long pos)Seeks to the specified absolute position in the stream.longskip(long n)Seeksnbytes forward in this stream.
-
-
-
Method Detail
-
skip
public long skip(long n) throws java.io.IOExceptionSeeksnbytes forward in this stream.This will not seek past the end of the file. If the current position is already at or past the end of the file, this doesn't seek at all and returns
0. Otherwise, if skippingnbytes would cause the position to exceed the stream size, this will do equivalent ofseek(length())and the return value will be adjusted accordingly.If
nis negative, the position isn't changed and the return value is0. It doesn't seek backward because it would conflict with the specification ofInputStream.skip.- Overrides:
skipin classjava.io.InputStream- Returns:
0ifnis negative, less thannif skippingnbytes would seek past the end of the file,notherwise- Throws:
java.io.IOException- might be thrown byseek(long)
-
length
public abstract long length() throws java.io.IOExceptionGets the size of the stream.- Throws:
java.io.IOException
-
position
public abstract long position() throws java.io.IOExceptionGets the current position in the stream.- Throws:
java.io.IOException
-
seek
public abstract void seek(long pos) throws java.io.IOExceptionSeeks to the specified absolute position in the stream.Seeking past the end of the file should be supported by the subclasses unless there is a good reason to do otherwise. If one has seeked past the end of the stream,
readwill return-1to indicate end of stream.- Parameters:
pos- new read position in the stream- Throws:
java.io.IOException- ifposis negative or if a stream-specific I/O error occurs
-
-