Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.archive.io
Class RandomAccessInputStream

    java.lang.Object
      java.io.InputStream
          org.archive.io.SeekInputStream
              org.archive.io.RandomAccessInputStream

All Implemented Interfaces:
  it.unimi.dsi.fastutil.io.RepositionableStream, java.io.Closeable

    public class RandomAccessInputStream

extends SeekInputStream

Wraps a RandomAccessFile with an InputStream interface.

Author:
  gojomo

Constructor Summary
`RandomAccessInputStream(java.io.File file)` Constructor.
`RandomAccessInputStream(java.io.File file, long offset)` Constructor.
`RandomAccessInputStream(java.io.RandomAccessFile raf)` Constructor.
`RandomAccessInputStream(java.io.RandomAccessFile raf, boolean sympathyClose, long offset)`

Method Summary
`int` | `available()`
`void` | `close()`
`void` | `mark(int readlimit)` Marks the current position of the stream.
`boolean` | `markSupported()` Returns true, since SeekInputStreams support mark/reset by default.
`long` | `position()`
`void` | `position(long position)`
`int` | `read()`
`int` | `read(byte[] b)`
`int` | `read(byte[] b, int off, int len)`
`void` | `reset()` Resets this stream to its marked position.
`long` | `skip(long n)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RandomAccessInputStream

    public RandomAccessInputStream(java.io.RandomAccessFile raf)
                            throws java.io.IOException

  Constructor. If using this constructor, caller created the RAF and therefore its assumed wants to control close of the RAF. The RAF.close is not called if this constructor is used on close of this stream.

  Parameters:
    `raf` - RandomAccessFile to wrap.
  Throws:
    `java.io.IOException`

### RandomAccessInputStream

    public RandomAccessInputStream(java.io.File file)
                            throws java.io.IOException

  Constructor.

  Parameters:
    `file` - File to get RAFIS on. Creates an RAF from passed file. Closes the created RAF when this stream is closed.
  Throws:
    `java.io.IOException`

### RandomAccessInputStream

    public RandomAccessInputStream(java.io.File file,
                                   long offset)
                            throws java.io.IOException

  Constructor.

  Parameters:
    `file` - File to get RAFIS on. Creates an RAF from passed file. Closes the created RAF when this stream is closed.
    `offset` -
  Throws:
    `java.io.IOException`

### RandomAccessInputStream

    public RandomAccessInputStream(java.io.RandomAccessFile raf,
                                   boolean sympathyClose,
                                   long offset)
                            throws java.io.IOException

Parameters:
  `raf` - RandomAccessFile to wrap.
  `sympathyClose` - Set to true if we are to close the RAF file when this stream is closed.
  `offset` -
Throws:
  `java.io.IOException`

Method Detail

### read

    public int read()
             throws java.io.IOException

  Specified by:
    `read` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### read

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

  Overrides:
    `read` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### read

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

  Overrides:
    `read` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### skip

    public long skip(long n)
              throws java.io.IOException

  Overrides:
    `skip` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### position

    public long position()
                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### position

    public void position(long position)
                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### available

    public int available()
                  throws java.io.IOException

  Overrides:
    `available` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### markSupported

    public boolean markSupported()

  Description copied from class: `SeekInputStream`
  Returns true, since SeekInputStreams support mark/reset by default.

  Overrides:
    `markSupported` in class `SeekInputStream`
  Returns:
    true

### mark

    public void mark(int readlimit)

  Description copied from class: `SeekInputStream`
  Marks the current position of the stream. The limit parameter is ignored; the mark will remain valid until reset is called or the stream is closed.

  Overrides:
    `mark` in class `SeekInputStream`
  Parameters:
    `readlimit` - ignored

### reset

    public void reset()
               throws java.io.IOException

  Description copied from class: `SeekInputStream`
  Resets this stream to its marked position.

  Overrides:
    `reset` in class `SeekInputStream`
  Throws:
    `java.io.IOException` - if there is no mark, or if an IO error occurs

### close

    public void close()
               throws java.io.IOException

  Specified by:
    `close` in interface `java.io.Closeable`
  Overrides:
    `close` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Internet Archive. All Rights Reserved.