org.tukaani.xz
Class SeekableFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.tukaani.xz.SeekableInputStream
          extended by org.tukaani.xz.SeekableFileInputStream
All Implemented Interfaces:
Closeable

public class SeekableFileInputStream
extends SeekableInputStream

Wraps a RandomAccessFile in a SeekableInputStream.


Field Summary
protected  RandomAccessFile randomAccessFile
          The RandomAccessFile that has been wrapped into a SeekableFileInputStream.
 
Constructor Summary
SeekableFileInputStream(File file)
          Creates a new seekable input stream that reads from the specified file.
SeekableFileInputStream(RandomAccessFile randomAccessFile)
          Creates a new seekable input stream from an existing RandomAccessFile object.
SeekableFileInputStream(String name)
          Creates a new seekable input stream that reads from a file with the specified name.
 
Method Summary
 void close()
          Calls randomAccessFile.close().
 long length()
          Calls randomAccessFile.length().
 long position()
          Calls randomAccessFile.getFilePointer().
 int read()
          Calls randomAccessFile.read().
 int read(byte[] buf)
          Calls randomAccessFile.read(buf).
 int read(byte[] buf, int off, int len)
          Calls randomAccessFile.read(buf, off, len).
 void seek(long pos)
          Calls randomAccessFile.seek(long).
 
Methods inherited from class org.tukaani.xz.SeekableInputStream
skip
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

randomAccessFile

protected RandomAccessFile randomAccessFile
The RandomAccessFile that has been wrapped into a SeekableFileInputStream.

Constructor Detail

SeekableFileInputStream

public SeekableFileInputStream(File file)
                        throws FileNotFoundException
Creates a new seekable input stream that reads from the specified file.

Throws:
FileNotFoundException

SeekableFileInputStream

public SeekableFileInputStream(String name)
                        throws FileNotFoundException
Creates a new seekable input stream that reads from a file with the specified name.

Throws:
FileNotFoundException

SeekableFileInputStream

public SeekableFileInputStream(RandomAccessFile randomAccessFile)
Creates a new seekable input stream from an existing RandomAccessFile object.

Method Detail

read

public int read()
         throws IOException
Calls randomAccessFile.read().

Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buf)
         throws IOException
Calls randomAccessFile.read(buf).

Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Calls randomAccessFile.read(buf, off, len).

Overrides:
read in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Calls randomAccessFile.close().

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

length

public long length()
            throws IOException
Calls randomAccessFile.length().

Specified by:
length in class SeekableInputStream
Throws:
IOException

position

public long position()
              throws IOException
Calls randomAccessFile.getFilePointer().

Specified by:
position in class SeekableInputStream
Throws:
IOException

seek

public void seek(long pos)
          throws IOException
Calls randomAccessFile.seek(long).

Specified by:
seek in class SeekableInputStream
Parameters:
pos - new read position in the stream
Throws:
IOException - if pos is negative or if a stream-specific I/O error occurs