Module ij
Package ij.io

# Class RandomAccessStream

java.lang.Object
java.io.InputStream
ij.io.RandomAccessStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public final class RandomAccessStream extends InputStream
This class uses a memory cache to allow seeking within an InputStream. Based on the JAI MemoryCacheSeekableStream class. Can also be constructed from a RandomAccessFile, which uses less memory since the memory cache is not required.

## Constructor Summary

Constructors
Constructor
Description
`RandomAccessStream(InputStream inputstream)`
Constructs a RandomAccessStream from an InputStream.
`RandomAccessStream(RandomAccessFile ras)`
Constructs a RandomAccessStream from an RandomAccessFile.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`int`
`getFilePointer()`
`long`
`getLongFilePointer()`
`int`
`read()`
`int`
`read(byte[] bytes, int off, int len)`
`final double`
`readDouble()`
`final float`
`readFloat()`
`final void`
`readFully(byte[] bytes)`
`final void`
`readFully(byte[] bytes, int len)`
`final int`
`readInt()`
`final long`
`readLong()`
`final short`
`readShort()`
`void`
`seek(int loc)`
`void`
`seek(long loc)`

### Methods inherited from class java.io.InputStream

`available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### RandomAccessStream

public RandomAccessStream(InputStream inputstream)
Constructs a RandomAccessStream from an InputStream. Seeking backwards is supported using a memory cache.

### RandomAccessStream

public RandomAccessStream(RandomAccessFile ras)
Constructs a RandomAccessStream from an RandomAccessFile.

## Method Details

### getFilePointer

public int getFilePointer() throws IOException

Throws:
  `IOException`

### getLongFilePointer

public long getLongFilePointer() throws IOException

Throws:
  `IOException`

### read

public int read() throws IOException

Specified by:
  `read` in class `InputStream`
Throws:
  `IOException`

### read

public int read(byte[] bytes, int off, int len) throws IOException

Overrides:
  `read` in class `InputStream`
Throws:
  `IOException`

### readFully

public final void readFully(byte[] bytes) throws IOException

Throws:
  `IOException`

### readFully

public final void readFully(byte[] bytes, int len) throws IOException

Throws:
  `IOException`

### seek

public void seek(long loc) throws IOException

Throws:
  `IOException`

### seek

public void seek(int loc) throws IOException

Throws:
  `IOException`

### readInt

public final int readInt() throws IOException

Throws:
  `IOException`

### readLong

public final long readLong() throws IOException

Throws:
  `IOException`

### readDouble

public final double readDouble() throws IOException

Throws:
  `IOException`

### readShort

public final short readShort() throws IOException

Throws:
  `IOException`

### readFloat

public final float readFloat() throws IOException

Throws:
  `IOException`

### close

public void close() throws IOException

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