Top Description Fields Constructors Methods
org.tukaani.xz

public Class SeekableFileInputStream

extends SeekableInputStream
Class Inheritance
Imports
java.io.File, .RandomAccessFile, .IOException, .FileNotFoundException

Wraps a RandomAccessFile in a SeekableInputStream.

Field Summary

Modifier and TypeField and Description
protected RandomAccessFile
randomAccessFile

The RandomAccessFile that has been wrapped into a SeekableFileInputStream.

Constructor Summary

AccessConstructor and Description
public
SeekableFileInputStream(File file)

Creates a new seekable input stream that reads from the specified file.

public
SeekableFileInputStream(String name)

Creates a new seekable input stream that reads from a file with the specified name.

public
SeekableFileInputStream(RandomAccessFile randomAccessFile)

Creates a new seekable input stream from an existing RandomAccessFile object.

Method Summary

Modifier and TypeMethod and Description
public void
public long
public long
public int
public int
read(byte[]
the buffer into which the data is read.
buf
)

Overrides java.io.InputStream.read.

Calls randomAccessFile.read(buf).
public int
read(byte[]
the buffer into which the data is read.
buf
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Calls randomAccessFile.read(buf, off, len).
public void
seek(long
new read position in the stream
pos
)

Implements abstract org.tukaani.xz.SeekableInputStream.seek.

Calls randomAccessFile.seek(long).
Inherited from org.tukaani.xz.SeekableInputStream:
skip

Field Detail

randomAccessFileback to summary
protected RandomAccessFile randomAccessFile

The RandomAccessFile that has been wrapped into a SeekableFileInputStream.

Constructor Detail

SeekableFileInputStreamback to summary
public SeekableFileInputStream(File file) throws FileNotFoundException

Creates a new seekable input stream that reads from the specified file.

SeekableFileInputStreamback to summary
public SeekableFileInputStream(String name) throws FileNotFoundException

Creates a new seekable input stream that reads from a file with the specified name.

SeekableFileInputStreamback to summary
public SeekableFileInputStream(RandomAccessFile randomAccessFile)

Creates a new seekable input stream from an existing RandomAccessFile object.

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Calls randomAccessFile.close().

Exceptions
IOException:

Doc from java.io.InputStream.close.

if an I/O error occurs.

lengthback to summary
public long length() throws IOException

Implements abstract org.tukaani.xz.SeekableInputStream.length.

Calls randomAccessFile.length().

positionback to summary
public long position() throws IOException

Implements abstract org.tukaani.xz.SeekableInputStream.position.

Calls randomAccessFile.getFilePointer().

readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Calls randomAccessFile.read().

Returns:int

Doc from java.io.InputStream.read.

the next byte of data, or -1 if the end of the stream is reached.

Exceptions
IOException:

Doc from java.io.InputStream.read.

if an I/O error occurs.

readback to summary
public int read(byte[] buf) throws IOException

Overrides java.io.InputStream.read.

Calls randomAccessFile.read(buf).

Parameters
buf:byte[]

Doc from java.io.InputStream.read.

the buffer into which the data is read.

Returns:int

Doc from java.io.InputStream.read.

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.

Exceptions
IOException:

Doc from java.io.InputStream.read.

If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.

readback to summary
public int read(byte[] buf, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Calls randomAccessFile.read(buf, off, len).

Parameters
buf:byte[]

Doc from java.io.InputStream.read.

the buffer into which the data is read.

off:int

Doc from java.io.InputStream.read.

the start offset in array b at which the data is written.

len:int

Doc from java.io.InputStream.read.

the maximum number of bytes to read.

Returns:int

Doc from java.io.InputStream.read.

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.

Exceptions
IOException:

Doc from java.io.InputStream.read.

If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.

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

Implements abstract org.tukaani.xz.SeekableInputStream.seek.

Calls randomAccessFile.seek(long).

Parameters
pos:long

Doc from org.tukaani.xz.SeekableInputStream.seek.

new read position in the stream

Exceptions
IOException:

Doc from org.tukaani.xz.SeekableInputStream.seek.

if pos is negative or if a stream-specific I/O error occurs