Top Description Constructors Methods
org.tukaani.xz

public abstract Class SeekableInputStream

extends InputStream
Class Inheritance
Known Direct Subclasses
org.tukaani.xz.SeekableXZInputStream, org.tukaani.xz.SeekableFileInputStream
Imports
java.io.InputStream, .IOException

Input stream with random access support.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract long
length()

Gets the size of the stream.

public abstract long
position()

Gets the current position in the stream.

public abstract void
seek(long
new read position in the stream
pos
)

Seeks to the specified absolute position in the stream.

public long

Returns:

0 if n is negative, less than n if skipping n bytes would seek past the end of the file, n otherwise
skip
(long
the number of bytes to be skipped.
n
)

Overrides java.io.InputStream.skip.

Seeks n bytes forward in this stream.
Inherited from java.io.InputStream:
availableclosemarkmarkSupportednullInputStreamreadreadreadreadAllBytesreadNBytesreadNBytesresetskipNBytestransferTo

Constructor Detail

SeekableInputStreamback to summary
public SeekableInputStream()

Method Detail

lengthback to summary
public abstract long length() throws IOException

Gets the size of the stream.

positionback to summary
public abstract long position() throws IOException

Gets the current position in the stream.

seekback to summary
public abstract void seek(long pos) throws IOException

Seeks 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, read will return -1 to indicate end of stream.

Parameters
pos:long

new read position in the stream

Exceptions
IOException:
if pos is negative or if a stream-specific I/O error occurs
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.InputStream.skip.

Seeks n bytes 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 skipping n bytes would cause the position to exceed the stream size, this will do equivalent of seek(length()) and the return value will be adjusted accordingly.

If n is negative, the position isn't changed and the return value is 0. It doesn't seek backward because it would conflict with the specification of InputStream.skip.

Parameters
n:long

Doc from java.io.InputStream.skip.

the number of bytes to be skipped.

Returns:long

0 if n is negative, less than n if skipping n bytes would seek past the end of the file, n otherwise

Exceptions
IOException:
might be thrown by seek(long)