Smb Random Access File
Provides a java.io.RandomAccessFile-compatible random-access API over a remote SMB file.
Maintains an internal file pointer (position) and supports seeking to arbitrary offsets (seek), reading from the current position (read, readByte, readFully), writing at the current position (write), and querying or changing the file length (length / setLength).
For workloads with frequent small reads (such as readByte or container header parsing), pass a positive bufferSize to enable an in-memory read-ahead buffer (defaults to 0, disabling buffering). Any write or size change immediately invalidates the read buffer to preserve read-after-write consistency.
Like java.io.RandomAccessFile, a single SmbRandomAccessFile instance is designed for sequential use from one thread at a time. To read concurrently from multiple threads, open a separate SmbRandomAccessFile instance per thread (the underlying SmbShare and SmbClient are thread-safe and can be shared).
Constructors
Properties
Functions
Closes the remote SMB file handle on the server (SMB2 CLOSE) and releases internal buffers.
Opens the remote SMB file if it is not already open.
Reads a single byte from the current position and returns it as an integer in the range 0..255, or -1 if the end of the file has been reached.
Reads up to b.size bytes from the current position into b and returns the number of bytes read, or -1 if no bytes could be read because the end of the file has been reached.
Reads a single byte from the current position and returns true if it is non-zero, or false if zero.
Reads a signed 8-bit value (Byte) from the current position and advances the file pointer by 1. Throws SmbEndOfFileException if the end of the file has been reached.
Reads an unsigned 8-bit value (0..255) from the current position and advances the file pointer by 1. Throws SmbEndOfFileException if the end of the file has been reached.
Reads an unsigned 16-bit big-endian integer from the current position.
Writes a boolean value as a single byte (1 for true, 0 for false) at the current position.
Writes a 16-bit big-endian integer at the current position.