RandomAccessReader

RandomAccessReader

Overview

RandomAccessReader is a class in Aspose.Pdf FOSS for Java. Inherits from: Closeable.

Random-access reader for PDF files.

Properties

NameTypeAccessDescription
positionlongReadReturns the current read position.
lengthlongReadReturns the total length of the data source.
eOFbooleanReadReturns {@code true} if the current position is at or past the end of data.

Methods

SignatureDescription
fromFile(file: File)RandomAccessReaderCreates a reader backed by a file.
fromFile(path: Path)RandomAccessReaderCreates a reader backed by a file.
fromBytes(data: byte[])RandomAccessReaderCreates a reader backed by an in-memory byte array.
fromStream(is: InputStream)RandomAccessReaderCreates a reader by reading the entire input stream into memory.
getPosition()longReturns the current read position.
getLength()longReturns 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()intReads a single byte at the current position and advances by one.
read(buf: byte[], off: int, len: int)intReads 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()intReads the next byte without advancing the position.
readLine()StringReads an ASCII line (terminated by LF or CR+LF).
isEOF()booleanReturns {@code true} if the current position is at or past the end of data.
findBackward(pattern: byte[], startFrom: long)longSearches backward from {@code startFrom} for the given byte pattern.
findForward(pattern: byte[], startFrom: long)longSearches forward from the given position for the first occurrence of the pattern.
close()Closes this reader and releases any underlying resources.

See Also