RandomAccessReader
Overview
RandomAccessReader is a class in Aspose.Pdf FOSS for Java.
Inherits from: Closeable.
Random-access reader for PDF files.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
position | long | Read | Returns the current read position. |
length | long | Read | Returns the total length of the data source. |
eOF | boolean | Read | Returns {@code true} if the current position is at or past the end of data. |
Methods
| Signature | Description |
|---|---|
fromFile(file: File) → RandomAccessReader | Creates a reader backed by a file. |
fromFile(path: Path) → RandomAccessReader | Creates a reader backed by a file. |
fromBytes(data: byte[]) → RandomAccessReader | Creates a reader backed by an in-memory byte array. |
fromStream(is: InputStream) → RandomAccessReader | Creates a reader by reading the entire input stream into memory. |
getPosition() → long | Returns the current read position. |
getLength() → long | Returns the total length of the data source. |
seek(pos: long) | Seeks to the given absolute position. |
skip(n: long) | Advances the position by the given number of bytes. |
read() → int | Reads a single byte at the current position and advances by one. |
read(buf: byte[], off: int, len: int) → int | Reads up to {@code len} bytes into the given array. |
readFully(len: int) → byte[] | Reads exactly {@code length} bytes, throwing {@link EOFException} if not enough data is available. |
peek() → int | Reads the next byte without advancing the position. |
readLine() → String | Reads an ASCII line (terminated by LF or CR+LF). |
isEOF() → boolean | Returns {@code true} if the current position is at or past the end of data. |
findBackward(pattern: byte[], startFrom: long) → long | Searches backward from {@code startFrom} for the given byte pattern. |
findForward(pattern: byte[], startFrom: long) → long | Searches forward from the given position for the first occurrence of the pattern. |
close() | Closes this reader and releases any underlying resources. |