SeekableFileInputStream
Date: 2017-02-08

org.tukaani.xz

## Class SeekableFileInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.tukaani.xz.SeekableInputStream
    - - org.tukaani.xz.SeekableFileInputStream

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class SeekableFileInputStream
      extends SeekableInputStream

  Wraps a `RandomAccessFile` in a SeekableInputStream.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.io.RandomAccessFile` | `randomAccessFile` The RandomAccessFile that has been wrapped into a SeekableFileInputStream.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SeekableFileInputStream(java.io.File file)` Creates a new seekable input stream that reads from the specified file.
    `SeekableFileInputStream(java.io.RandomAccessFile randomAccessFile)` Creates a new seekable input stream from an existing `RandomAccessFile` object.
    `SeekableFileInputStream(java.lang.String name)` Creates a new seekable input stream that reads from a file with the specified name.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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 java.io.RandomAccessFile randomAccessFile

      The RandomAccessFile that has been wrapped into a SeekableFileInputStream.

  - ### Constructor Detail

    - #### SeekableFileInputStream

          public SeekableFileInputStream(java.io.File file)
                                  throws java.io.FileNotFoundException

      Creates a new seekable input stream that reads from the specified file.
      Throws:
        `java.io.FileNotFoundException`

    - #### SeekableFileInputStream

          public SeekableFileInputStream(java.lang.String name)
                                  throws java.io.FileNotFoundException

      Creates a new seekable input stream that reads from a file with the specified name.
      Throws:
        `java.io.FileNotFoundException`

    - #### SeekableFileInputStream

          public SeekableFileInputStream(java.io.RandomAccessFile randomAccessFile)

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

  - ### Method Detail

    - #### read

          public int read()
                   throws java.io.IOException

      Calls `randomAccessFile.read()`.
      Specified by:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### read

          public int read(byte[] buf)
                   throws java.io.IOException

      Calls `randomAccessFile.read(buf)`.
      Overrides:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### read

          public int read(byte[] buf,
                 int off,
                 int len)
                   throws java.io.IOException

      Calls `randomAccessFile.read(buf, off, len)`.
      Overrides:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Calls `randomAccessFile.close()`.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### length

          public long length()
                      throws java.io.IOException

      Calls `randomAccessFile.length()`.
      Specified by:
        `length` in class `SeekableInputStream`
      Throws:
        `java.io.IOException`

    - #### position

          public long position()
                        throws java.io.IOException

      Calls `randomAccessFile.getFilePointer()`.
      Specified by:
        `position` in class `SeekableInputStream`
      Throws:
        `java.io.IOException`

    - #### seek

          public void seek(long pos)
                    throws java.io.IOException

      Calls `randomAccessFile.seek(long)`.
      Specified by:
        `seek` in class `SeekableInputStream`
      Parameters:
        `pos` - new read position in the stream
      Throws:
        `java.io.IOException` - if `pos` is negative or if a stream-specific I/O error occurs