Class BufferedFile

java.lang.Object
io.smallrye.common.io.BufferedFile
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public final class BufferedFile extends Object implements Closeable, Flushable
A buffered random-access file that supports reading and writing variously-sized integers, floating-point values, byte arrays, NIO ByteBuffers, and strings at both the current file position and at explicit (random-access) file positions.

The buffer is used for both reading and writing. Sequential read and write operations advance the file position; random-access operations (those accepting an explicit position parameter) do not. The default byte order is configurable and may be changed during the lifetime of the file; explicit little-endian and big-endian method variants are also provided.

Thread safety

This class uses a lightweight compare-and-swap lock to detect illegal concurrent access. If two threads attempt to use the same instance concurrently, the second thread will receive an IllegalStateException. Re-entrant calls from the same thread are permitted (the lock is recursive within a single thread).

Stream and channel views

The inputStream() and outputStream() methods return cached views that extend FileInputStream and FileOutputStream respectively and also implement DataInput and DataOutput (with the big-endian semantics mandated by those interfaces, independent of this file's configured byte order). The channel() method returns a cached FileChannel view.

The input and output stream views share a single file position with this BufferedFile, so mixing their usage may produce unexpected results unless the shared position is explicitly considered.

Calling close() on any view is a no-op; closing the BufferedFile itself closes all views.

Append mode

Append mode is not supported by this API.

File descriptor and buffering caveats

The file descriptor is exposed for advanced use, but directly accessing or modifying the file position through the file descriptor will result in inconsistent behavior. Furthermore, the backing file may not reflect buffered data that has not yet been flushed.

Byte order

The byte order used by methods on this class is the configurable default (or the explicit LE/BE variant). This differs from the DataInput/DataOutput methods on the stream views, which always use big-endian per their contract. The writeFloat(float)/writeDouble(double) methods use raw bit patterns (Float.floatToRawIntBits(float), Double.doubleToRawLongBits(double)), preserving NaN payloads.

Buffer boundary behavior

Random-access operations that partially overlap the buffer boundary are decomposed into smaller sub-operations; this is a rare edge case and not a performance concern in practice.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    final class 
    A FileChannel view that delegates to the enclosing BufferedFile, maintaining buffer consistency for all read/write/position operations.
    final class 
    An InputStream view that extends FileInputStream and implements DataInput with big-endian semantics.
    final class 
    An OutputStream view that extends FileOutputStream and implements DataOutput with big-endian semantics.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the current default byte order.
    void
    byteOrder(ByteOrder byteOrder)
    Set the default byte order.
    Returns a cached FileChannel view of this file.
    void
    Flush any buffered data and close this file.
    Returns the file descriptor for this file.
    long
    Returns the current file position.
    int
    fill(int bytes)
    Attempt to fill the buffer with at least bytes bytes of data.
    void
    Flush any buffered data to the file.
    Returns a cached FileInputStream view of this file.
    long
    Returns the current file length, including any buffered but unflushed data.
    Create a nested view of this file starting at the current file position.
    openNested(Closeable closeAction)
    Create a nested view of this file starting at the current file position.
    Returns a cached FileOutputStream view of this file.
    int
    Read a single byte at the current position without advancing.
    byte
    Read a single byte at the current position without advancing.
    int
    Read a 32-bit value at the current position using the default byte order without advancing.
    int
    Read a 32-bit value at the current position using big-endian byte order without advancing.
    int
    Read a 32-bit value at the current position using little-endian byte order without advancing.
    long
    Read a 64-bit value at the current position using the default byte order without advancing.
    long
    Read a 64-bit value at the current position using big-endian byte order without advancing.
    long
    Read a 64-bit value at the current position using little-endian byte order without advancing.
    short
    Read a 16-bit value at the current position using the default byte order without advancing.
    short
    Read a 16-bit value at the current position using big-endian byte order without advancing.
    short
    Read a 16-bit value at the current position using little-endian byte order without advancing.
    int
    Read a single unsigned byte at the current position without advancing.
    long
    Read a 32-bit unsigned value at the current position using the default byte order without advancing.
    long
    Read a 32-bit unsigned value at the current position using big-endian byte order without advancing.
    long
    Read a 32-bit unsigned value at the current position using little-endian byte order without advancing.
    int
    Read an unsigned 16-bit value at the current position using the default byte order without advancing.
    int
    Read an unsigned 16-bit value at the current position using big-endian byte order without advancing.
    int
    Read an unsigned 16-bit value at the current position using little-endian byte order without advancing.
    int
    Read a single byte at the current position and advance.
    int
    read(byte[] dest)
    Read bytes into the given array at the current position and advance.
    int
    read(byte[] dest, int offset, int length)
    Read bytes into the given array at the current position and advance.
    int
    read(long pos, byte[] dest)
    Read bytes at the given file position without changing the current position.
    int
    read(long pos, byte[] dest, int offset, int length)
    Read bytes at the given file position without changing the current position.
    int
    read(long pos, ByteBuffer dest)
    Read into the given ByteBuffer at the given file position without changing the current position.
    int
    Read into the given ByteBuffer at the current position and advance.
    boolean
    Read a boolean value (1 byte: 0 for false, non-zero for true) and advance.
    boolean
    readBoolean(long pos)
    Read a boolean value at the given file position without advancing the current position.
    byte
    Read a single byte at the current position and advance.
    byte
    readByte(long pos)
    Read a single byte at the given file position without changing the current position.
    char
    Read a 16-bit char at the current position using the default byte order and advance.
    char
    readChar(long pos)
    Read a 16-bit character value at the given file position using the default byte order without advancing the current position.
    char
    Read a 16-bit character value at the current position using big-endian byte order and advance.
    char
    readCharBE(long pos)
    Read a 16-bit character value at the given file position using big-endian byte order without advancing the current position.
    char
    Read a 16-bit character value at the current position using little-endian byte order and advance.
    char
    readCharLE(long pos)
    Read a 16-bit character value at the given file position using little-endian byte order without advancing the current position.
    double
    Read a 64-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
    double
    readDouble(long pos)
    Read a 64-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
    double
    Read a 64-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
    double
    readDoubleBE(long pos)
    Read a 64-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
    double
    Read a 64-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
    double
    readDoubleLE(long pos)
    Read a 64-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
    float
    Read a 32-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
    float
    readFloat(long pos)
    Read a 32-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
    float
    Read a 32-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
    float
    readFloatBE(long pos)
    Read a 32-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
    float
    Read a 32-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
    float
    readFloatLE(long pos)
    Read a 32-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
    void
    readFully(byte[] dest)
    Read exactly dest.length bytes from the current position into the given array and advance.
    void
    readFully(byte[] dest, int offset, int length)
    Read exactly length bytes at the current position and advance.
    int
    Read a 32-bit value at the current position using the default byte order and advance.
    int
    readInt(long pos)
    Read a 32-bit value at the given file position using the default byte order without advancing the current position.
    int
    Read a 32-bit value at the current position using big-endian byte order and advance.
    int
    readIntBE(long pos)
    Read a 32-bit value at the given file position using big-endian byte order without advancing the current position.
    int
    Read a 32-bit value at the current position using little-endian byte order and advance.
    int
    readIntLE(long pos)
    Read a 32-bit value at the given file position using little-endian byte order without advancing the current position.
    long
    Read a 64-bit value at the current position using the default byte order and advance.
    long
    readLong(long pos)
    Read a 64-bit value at the given file position using the default byte order without advancing the current position.
    long
    Read a 64-bit value at the current position using big-endian byte order and advance.
    long
    readLongBE(long pos)
    Read a 64-bit value at the given file position using big-endian byte order without advancing the current position.
    long
    Read a 64-bit value at the current position using little-endian byte order and advance.
    long
    readLongLE(long pos)
    Read a 64-bit value at the given file position using little-endian byte order without advancing the current position.
    short
    Read a 16-bit value at the current position using the default byte order and advance.
    short
    readShort(long pos)
    Read a 16-bit value at the given file position using the default byte order without changing the current position.
    short
    Read a 16-bit value at the current position using big-endian byte order and advance.
    short
    readShortBE(long pos)
    Read a 16-bit value at the given file position using big-endian byte order without advancing the current position.
    short
    Read a 16-bit value at the current position using little-endian byte order and advance.
    short
    readShortLE(long pos)
    Read a 16-bit value at the given file position using little-endian byte order without advancing the current position.
    readString(int byteLength)
    Read a fixed number of bytes and decode as a UTF-8 string.
    readString(int byteLength, Charset charset)
    Read a fixed number of bytes and decode as a string using the given charset.
    int
    Read a single unsigned byte at the current position and advance.
    int
    readUnsignedByte(long pos)
    Read a single unsigned byte at the given file position without changing the current position.
    long
    Read a 32-bit unsigned value at the current position using the default byte order and advance.
    long
    readUnsignedInt(long pos)
    Read an unsigned 32-bit value at the given file position using the default byte order without changing the current position.
    long
    Read a 32-bit unsigned value at the current position using big-endian byte order and advance.
    long
    Read an unsigned 32-bit value at the given file position using big-endian byte order without advancing the current position.
    long
    Read a 32-bit unsigned value at the current position using little-endian byte order and advance.
    long
    Read an unsigned 32-bit value at the given file position using little-endian byte order without advancing the current position.
    int
    Read an unsigned 16-bit value at the current position using the default byte order and advance.
    int
    Read an unsigned 16-bit value at the given file position using the default byte order without changing the current position.
    int
    Read an unsigned 16-bit value at the current position using big-endian byte order and advance.
    int
    Read an unsigned 16-bit value at the given file position using big-endian byte order without advancing the current position.
    int
    Read an unsigned 16-bit value at the current position using little-endian byte order and advance.
    int
    Read an unsigned 16-bit value at the given file position using little-endian byte order without advancing the current position.
    Read a zero-terminated UTF-8 string and advance past the terminator.
    Read a zero-terminated string using the given charset and advance past the terminator.
    long
    Returns the number of bytes between the current position and the end of the file.
    void
    seek(long position)
    Set the file position.
    void
    setLength(long newLength)
    Set the length of the file.
    long
    skip(long count)
    Skip forward by the given number of bytes.
    long
    transferFrom(long pos, InputStream in, long length)
    Transfer bytes from the given input stream to the given file position without changing the current position.
    long
    Transfer all bytes from the given input stream to the current position.
    long
    transferFrom(InputStream in, long length)
    Transfer up to length bytes from the given input stream to the current position.
    long
    transferTo(long pos, OutputStream out, long length)
    Transfer bytes from the given file position to the output stream without changing the current position.
    long
    Transfer all remaining bytes from the current position to the given output stream.
    long
    transferTo(OutputStream out, long length)
    Transfer up to length bytes from the current position to the given output stream.
    void
    write(byte[] src)
    Write all bytes from the given array to the current position and advance.
    void
    write(byte[] src, int offset, int length)
    Write bytes from the given array at the current position and advance.
    void
    write(long pos, byte[] src, int offset, int length)
    Write bytes at the given file position without changing the current position.
    int
    write(long pos, ByteBuffer src)
    Write from the given ByteBuffer at the given file position without changing the current position.
    void
    Write from the given ByteBuffer at the current position and advance.
    void
    writeBoolean(boolean value)
    Write a boolean value (1 byte: 0 for false, 1 for true) and advance.
    void
    writeBoolean(long pos, boolean value)
    Write a boolean value at the given file position without advancing the current position.
    void
    writeByte(int value)
    Write a single byte at the current position and advance.
    void
    writeByte(long pos, int value)
    Write a single byte at the given file position without changing the current position.
    void
    writeChar(int value)
    Write a 16-bit char at the current position using the default byte order and advance.
    void
    writeChar(long pos, int value)
    Write a 16-bit character value at the given file position using the default byte order without advancing the current position.
    void
    writeCharBE(int value)
    Write a 16-bit character value at the current position using big-endian byte order and advance.
    void
    writeCharBE(long pos, int value)
    Write a 16-bit character value at the given file position using big-endian byte order without advancing the current position.
    void
    writeCharLE(int value)
    Write a 16-bit character value at the current position using little-endian byte order and advance.
    void
    writeCharLE(long pos, int value)
    Write a 16-bit character value at the given file position using little-endian byte order without advancing the current position.
    void
    writeDouble(double value)
    Write a 64-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
    void
    writeDouble(long pos, double value)
    Write a 64-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
    void
    writeDoubleBE(double value)
    Write a 64-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
    void
    writeDoubleBE(long pos, double value)
    Write a 64-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
    void
    writeDoubleLE(double value)
    Write a 64-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
    void
    writeDoubleLE(long pos, double value)
    Write a 64-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
    void
    writeFloat(float value)
    Write a 32-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
    void
    writeFloat(long pos, float value)
    Write a 32-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
    void
    writeFloatBE(float value)
    Write a 32-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
    void
    writeFloatBE(long pos, float value)
    Write a 32-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
    void
    writeFloatLE(float value)
    Write a 32-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
    void
    writeFloatLE(long pos, float value)
    Write a 32-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
    void
    writeInt(int value)
    Write a 32-bit value at the current position using the default byte order and advance.
    void
    writeInt(long pos, int value)
    Write a 32-bit value at the given file position using the default byte order without advancing the current position.
    void
    writeIntBE(int value)
    Write a 32-bit value at the current position using big-endian byte order and advance.
    void
    writeIntBE(long pos, int value)
    Write a 32-bit value at the given file position using big-endian byte order without advancing the current position.
    void
    writeIntLE(int value)
    Write a 32-bit value at the current position using little-endian byte order and advance.
    void
    writeIntLE(long pos, int value)
    Write a 32-bit value at the given file position using little-endian byte order without advancing the current position.
    void
    writeLong(long value)
    Write a 64-bit value at the current position using the default byte order and advance.
    void
    writeLong(long pos, long value)
    Write a 64-bit value at the given file position using the default byte order without advancing the current position.
    void
    writeLongBE(long value)
    Write a 64-bit value at the current position using big-endian byte order and advance.
    void
    writeLongBE(long pos, long value)
    Write a 64-bit value at the given file position using big-endian byte order without advancing the current position.
    void
    writeLongLE(long value)
    Write a 64-bit value at the current position using little-endian byte order and advance.
    void
    writeLongLE(long pos, long value)
    Write a 64-bit value at the given file position using little-endian byte order without advancing the current position.
    void
    writeShort(int value)
    Write a 16-bit value at the current position using the default byte order and advance.
    void
    writeShort(long pos, int value)
    Write a 16-bit value at the given file position using the default byte order without changing the current position.
    void
    writeShortBE(int value)
    Write a 16-bit value at the current position using big-endian byte order and advance.
    void
    writeShortBE(long pos, int value)
    Write a 16-bit value at the given file position using big-endian byte order without advancing the current position.
    void
    writeShortLE(int value)
    Write a 16-bit value at the current position using little-endian byte order and advance.
    void
    writeShortLE(long pos, int value)
    Write a 16-bit value at the given file position using little-endian byte order without advancing the current position.
    void
    Write a UTF-8-encoded string (no terminator) and advance.
    void
    writeString(String s, Charset charset)
    Write a string encoded with the given charset (no terminator) and advance.
    void
    writeZeros(long count)
    Write the given number of zero bytes at the current position and advance.
    void
    writeZeros(long pos, long count)
    Write zero bytes at the given file position without changing the current position.
    void
    Write a UTF-8-encoded string followed by a zero byte and advance.
    void
    Write a string encoded with the given charset, followed by a zero byte, and advance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • openNested

      public BufferedFile openNested() throws IOException
      Create a nested view of this file starting at the current file position. The returned view has its own buffer and position tracking; all positions are relative to the current position at the time of this call. The parent is unusable until the nested view is closed.
      Returns:
      the nested view (not null)
      Throws:
      IOException - if an I/O error occurs
      IllegalStateException - if a nested view is already active
    • openNested

      public BufferedFile openNested(Closeable closeAction) throws IOException
      Create a nested view of this file starting at the current file position. The returned view has its own buffer and position tracking; all positions are relative to the current position at the time of this call. The parent is unusable until the nested view is closed.

      The optional closeAction is invoked during the nested view's close() after the data is flushed and the parent is unlocked. This allows callers to perform post-processing (such as computing checksums and patching headers) by reading and writing the parent file.

      Parameters:
      closeAction - an action to invoke when the nested view is closed, or null
      Returns:
      the nested view (not null)
      Throws:
      IOException - if an I/O error occurs
      IllegalStateException - if a nested view is already active
    • fill

      public int fill(int bytes) throws IOException
      Attempt to fill the buffer with at least bytes bytes of data. If a value less than bytes is returned, then that is the number of bytes that can be read before reaching EOF (at the time of the call).

      If the buffer has remaining capacity, data is read into the buffer at the current end of valid data, extending the valid region without affecting the dirty state. If the buffer does not have enough remaining space, it is flushed (if dirty) and compacted before reading.

      Parameters:
      bytes - the minimum number of bytes to attempt to read (must not be negative, and must be less than the buffer size)
      Returns:
      the actual number of bytes currently available in the buffer, or -1 if end-of-file was reached and no bytes could be read
      Throws:
      IOException - if an I/O error occurs
    • filePosition

      public long filePosition() throws IOException
      Returns the current file position.
      Returns:
      the current file position
      Throws:
      IOException - if an I/O error occurs
    • seek

      public void seek(long position) throws IOException
      Set the file position.

      This method does not flush or invalidate the buffer. If the file has been truncated to a length smaller than the given position, subsequent sequential reads will see EOF and subsequent sequential writes will extend the file (with a zero-filled gap, per RandomAccessFile semantics).

      Parameters:
      position - the new file position
      Throws:
      IOException - if the file is in append mode, or if an I/O error occurs
    • length

      public long length() throws IOException
      Returns the current file length, including any buffered but unflushed data.
      Returns:
      the current file length, including any buffered but unflushed data
      Throws:
      IOException - if an I/O error occurs
    • remaining

      public long remaining() throws IOException
      Returns the number of bytes between the current position and the end of the file.
      Returns:
      the number of bytes between the current position and the end of the file
      Throws:
      IOException - if an I/O error occurs
    • setLength

      public void setLength(long newLength) throws IOException
      Set the length of the file.

      If newLength is less than the current length, the file is truncated. The current file position is not automatically adjusted; if it exceeds the new length, subsequent sequential reads will see EOF and sequential writes will extend the file with a zero-filled gap. Call seek(long) to reposition if needed.

      If the buffer window extends beyond the new length, the valid portion of the buffer is trimmed. If the entire buffer lies beyond the new length, it is invalidated.

      If newLength is greater than the current length, the file is extended with zero bytes (per RandomAccessFile semantics).

      Parameters:
      newLength - the desired file length
      Throws:
      IOException - if an I/O error occurs
    • skip

      public long skip(long count) throws IOException
      Skip forward by the given number of bytes.
      Parameters:
      count - the number of bytes to skip
      Returns:
      the number of bytes actually skipped
      Throws:
      IOException - if an I/O error occurs
    • fileDescriptor

      public FileDescriptor fileDescriptor() throws IOException
      Returns the file descriptor for this file.

      Warning: directly accessing or modifying the file position through this descriptor will result in inconsistent behavior. The backing file may not reflect buffered data that has not yet been flushed, among other potential issues.

      Returns:
      the file descriptor for this file
      Throws:
      IOException - if an I/O error occurs
    • byteOrder

      public ByteOrder byteOrder()
      Returns the current default byte order.
      Returns:
      the current default byte order
    • byteOrder

      public void byteOrder(ByteOrder byteOrder)
      Set the default byte order.
      Parameters:
      byteOrder - the new byte order (must not be null)
    • writeByte

      public void writeByte(int value) throws IOException
      Write a single byte at the current position and advance.
      Parameters:
      value - the byte value (only the low 8 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read() throws IOException
      Read a single byte at the current position and advance.
      Returns:
      the byte value (sign-extended to int), or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • peek

      public int peek() throws IOException
      Read a single byte at the current position without advancing.
      Returns:
      the byte value (sign-extended to int), or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • readByte

      public byte readByte() throws IOException
      Read a single byte at the current position and advance.
      Returns:
      the byte value
      Throws:
      EOFException - if end-of-file is reached
      IOException - if an I/O error occurs
    • peekByte

      public byte peekByte() throws IOException
      Read a single byte at the current position without advancing.
      Returns:
      the byte value
      Throws:
      EOFException - if end-of-file is reached
      IOException - if an I/O error occurs
    • readUnsignedByte

      public int readUnsignedByte() throws IOException
      Read a single unsigned byte at the current position and advance.
      Returns:
      the byte value as an unsigned int (in the range 0-255)
      Throws:
      EOFException - if end-of-file is reached
      IOException - if an I/O error occurs
    • peekUnsignedByte

      public int peekUnsignedByte() throws IOException
      Read a single unsigned byte at the current position without advancing.
      Returns:
      the byte value as an unsigned int (in the range 0-255)
      Throws:
      EOFException - if end-of-file is reached
      IOException - if an I/O error occurs
    • writeShort

      public void writeShort(int value) throws IOException
      Write a 16-bit value at the current position using the default byte order and advance.
      Parameters:
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • writeShortLE

      public void writeShortLE(int value) throws IOException
      Write a 16-bit value at the current position using little-endian byte order and advance.
      Parameters:
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • writeShortBE

      public void writeShortBE(int value) throws IOException
      Write a 16-bit value at the current position using big-endian byte order and advance.
      Parameters:
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • readShort

      public short readShort() throws IOException
      Read a 16-bit value at the current position using the default byte order and advance.
      Returns:
      the value (sign-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekShort

      public short peekShort() throws IOException
      Read a 16-bit value at the current position using the default byte order without advancing.
      Returns:
      the value (sign-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readShortLE

      public short readShortLE() throws IOException
      Read a 16-bit value at the current position using little-endian byte order and advance.
      Returns:
      the value (sign-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekShortLE

      public short peekShortLE() throws IOException
      Read a 16-bit value at the current position using little-endian byte order without advancing.
      Returns:
      the value (sign-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readShortBE

      public short readShortBE() throws IOException
      Read a 16-bit value at the current position using big-endian byte order and advance.
      Returns:
      the value (sign-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekShortBE

      public short peekShortBE() throws IOException
      Read a 16-bit value at the current position using big-endian byte order without advancing.
      Returns:
      the value (sign-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedShort

      public int readUnsignedShort() throws IOException
      Read an unsigned 16-bit value at the current position using the default byte order and advance.
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekUnsignedShort

      public int peekUnsignedShort() throws IOException
      Read an unsigned 16-bit value at the current position using the default byte order without advancing.
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedShortLE

      public int readUnsignedShortLE() throws IOException
      Read an unsigned 16-bit value at the current position using little-endian byte order and advance.
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekUnsignedShortLE

      public int peekUnsignedShortLE() throws IOException
      Read an unsigned 16-bit value at the current position using little-endian byte order without advancing.
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedShortBE

      public int readUnsignedShortBE() throws IOException
      Read an unsigned 16-bit value at the current position using big-endian byte order and advance.
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekUnsignedShortBE

      public int peekUnsignedShortBE() throws IOException
      Read an unsigned 16-bit value at the current position using big-endian byte order without advancing.
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeInt

      public void writeInt(int value) throws IOException
      Write a 32-bit value at the current position using the default byte order and advance.
      Parameters:
      value - the value
      Throws:
      IOException - if an I/O error occurs
    • writeIntLE

      public void writeIntLE(int value) throws IOException
      Write a 32-bit value at the current position using little-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeIntBE

      public void writeIntBE(int value) throws IOException
      Write a 32-bit value at the current position using big-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readInt

      public int readInt() throws IOException
      Read a 32-bit value at the current position using the default byte order and advance.
      Returns:
      the value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekInt

      public int peekInt() throws IOException
      Read a 32-bit value at the current position using the default byte order without advancing.
      Returns:
      the value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readIntLE

      public int readIntLE() throws IOException
      Read a 32-bit value at the current position using little-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekIntLE

      public int peekIntLE() throws IOException
      Read a 32-bit value at the current position using little-endian byte order without advancing.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readIntBE

      public int readIntBE() throws IOException
      Read a 32-bit value at the current position using big-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekIntBE

      public int peekIntBE() throws IOException
      Read a 32-bit value at the current position using big-endian byte order without advancing.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedInt

      public long readUnsignedInt() throws IOException
      Read a 32-bit unsigned value at the current position using the default byte order and advance.
      Returns:
      the unsigned value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekUnsignedInt

      public long peekUnsignedInt() throws IOException
      Read a 32-bit unsigned value at the current position using the default byte order without advancing.
      Returns:
      the unsigned value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedIntLE

      public long readUnsignedIntLE() throws IOException
      Read a 32-bit unsigned value at the current position using little-endian byte order and advance.
      Returns:
      the unsigned value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekUnsignedIntLE

      public long peekUnsignedIntLE() throws IOException
      Read a 32-bit unsigned value at the current position using little-endian byte order without advancing.
      Returns:
      the unsigned value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedIntBE

      public long readUnsignedIntBE() throws IOException
      Read a 32-bit unsigned value at the current position using big-endian byte order and advance.
      Returns:
      the unsigned value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekUnsignedIntBE

      public long peekUnsignedIntBE() throws IOException
      Read a 32-bit unsigned value at the current position using big-endian byte order without advancing.
      Returns:
      the unsigned value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeLong

      public void writeLong(long value) throws IOException
      Write a 64-bit value at the current position using the default byte order and advance.
      Parameters:
      value - the value
      Throws:
      IOException - if an I/O error occurs
    • writeLongLE

      public void writeLongLE(long value) throws IOException
      Write a 64-bit value at the current position using little-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeLongBE

      public void writeLongBE(long value) throws IOException
      Write a 64-bit value at the current position using big-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readLong

      public long readLong() throws IOException
      Read a 64-bit value at the current position using the default byte order and advance.
      Returns:
      the value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekLong

      public long peekLong() throws IOException
      Read a 64-bit value at the current position using the default byte order without advancing.
      Returns:
      the value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readLongLE

      public long readLongLE() throws IOException
      Read a 64-bit value at the current position using little-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekLongLE

      public long peekLongLE() throws IOException
      Read a 64-bit value at the current position using little-endian byte order without advancing.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readLongBE

      public long readLongBE() throws IOException
      Read a 64-bit value at the current position using big-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • peekLongBE

      public long peekLongBE() throws IOException
      Read a 64-bit value at the current position using big-endian byte order without advancing.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeFloat

      public void writeFloat(float value) throws IOException
      Write a 32-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeFloatLE

      public void writeFloatLE(float value) throws IOException
      Write a 32-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeFloatBE

      public void writeFloatBE(float value) throws IOException
      Write a 32-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readFloat

      public float readFloat() throws IOException
      Read a 32-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readFloatLE

      public float readFloatLE() throws IOException
      Read a 32-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readFloatBE

      public float readFloatBE() throws IOException
      Read a 32-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeDouble

      public void writeDouble(double value) throws IOException
      Write a 64-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeDoubleLE

      public void writeDoubleLE(double value) throws IOException
      Write a 64-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeDoubleBE

      public void writeDoubleBE(double value) throws IOException
      Write a 64-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
      Parameters:
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readDouble

      public double readDouble() throws IOException
      Read a 64-bit floating-point value using raw bit patterns at the current position using the default byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readDoubleLE

      public double readDoubleLE() throws IOException
      Read a 64-bit floating-point value using raw bit patterns at the current position using little-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readDoubleBE

      public double readDoubleBE() throws IOException
      Read a 64-bit floating-point value using raw bit patterns at the current position using big-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeBoolean

      public void writeBoolean(boolean value) throws IOException
      Write a boolean value (1 byte: 0 for false, 1 for true) and advance.
      Parameters:
      value - the boolean value
      Throws:
      IOException - if an I/O error occurs
    • readBoolean

      public boolean readBoolean() throws IOException
      Read a boolean value (1 byte: 0 for false, non-zero for true) and advance.
      Returns:
      the boolean value
      Throws:
      EOFException - if end-of-file is reached
      IOException - if an I/O error occurs
    • writeChar

      public void writeChar(int value) throws IOException
      Write a 16-bit char at the current position using the default byte order and advance.
      Parameters:
      value - the char value (only the low 16 bits of the int are used)
      Throws:
      IOException - if an I/O error occurs
    • writeCharLE

      public void writeCharLE(int value) throws IOException
      Write a 16-bit character value at the current position using little-endian byte order and advance.
      Parameters:
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • writeCharBE

      public void writeCharBE(int value) throws IOException
      Write a 16-bit character value at the current position using big-endian byte order and advance.
      Parameters:
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • readChar

      public char readChar() throws IOException
      Read a 16-bit char at the current position using the default byte order and advance.
      Returns:
      the char value
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readCharLE

      public char readCharLE() throws IOException
      Read a 16-bit character value at the current position using little-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readCharBE

      public char readCharBE() throws IOException
      Read a 16-bit character value at the current position using big-endian byte order and advance.
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeByte

      public void writeByte(long pos, int value) throws IOException
      Write a single byte at the given file position without changing the current position.
      Parameters:
      pos - the file position
      value - the byte value (only the low 8 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • readByte

      public byte readByte(long pos) throws IOException
      Read a single byte at the given file position without changing the current position.
      Parameters:
      pos - the file position
      Returns:
      the byte value
      Throws:
      EOFException - if end-of-file is reached
      IOException - if an I/O error occurs
    • readUnsignedByte

      public int readUnsignedByte(long pos) throws IOException
      Read a single unsigned byte at the given file position without changing the current position.
      Parameters:
      pos - the file position
      Returns:
      the unsigned byte value
      Throws:
      EOFException - if end-of-file is reached
      IOException - if an I/O error occurs
    • writeShort

      public void writeShort(long pos, int value) throws IOException
      Write a 16-bit value at the given file position using the default byte order without changing the current position.
      Parameters:
      pos - the file position
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • writeShortLE

      public void writeShortLE(long pos, int value) throws IOException
      Write a 16-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • writeShortBE

      public void writeShortBE(long pos, int value) throws IOException
      Write a 16-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • readShort

      public short readShort(long pos) throws IOException
      Read a 16-bit value at the given file position using the default byte order without changing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value (sign-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readShortLE

      public short readShortLE(long pos) throws IOException
      Read a 16-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readShortBE

      public short readShortBE(long pos) throws IOException
      Read a 16-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedShort

      public int readUnsignedShort(long pos) throws IOException
      Read an unsigned 16-bit value at the given file position using the default byte order without changing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedShortLE

      public int readUnsignedShortLE(long pos) throws IOException
      Read an unsigned 16-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedShortBE

      public int readUnsignedShortBE(long pos) throws IOException
      Read an unsigned 16-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeInt

      public void writeInt(long pos, int value) throws IOException
      Write a 32-bit value at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeIntLE

      public void writeIntLE(long pos, int value) throws IOException
      Write a 32-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeIntBE

      public void writeIntBE(long pos, int value) throws IOException
      Write a 32-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readInt

      public int readInt(long pos) throws IOException
      Read a 32-bit value at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readIntLE

      public int readIntLE(long pos) throws IOException
      Read a 32-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readIntBE

      public int readIntBE(long pos) throws IOException
      Read a 32-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedInt

      public long readUnsignedInt(long pos) throws IOException
      Read an unsigned 32-bit value at the given file position using the default byte order without changing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedIntLE

      public long readUnsignedIntLE(long pos) throws IOException
      Read an unsigned 32-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readUnsignedIntBE

      public long readUnsignedIntBE(long pos) throws IOException
      Read an unsigned 32-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value (zero-extended)
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeLong

      public void writeLong(long pos, long value) throws IOException
      Write a 64-bit value at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeLongLE

      public void writeLongLE(long pos, long value) throws IOException
      Write a 64-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeLongBE

      public void writeLongBE(long pos, long value) throws IOException
      Write a 64-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readLong

      public long readLong(long pos) throws IOException
      Read a 64-bit value at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readLongLE

      public long readLongLE(long pos) throws IOException
      Read a 64-bit value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readLongBE

      public long readLongBE(long pos) throws IOException
      Read a 64-bit value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeFloat

      public void writeFloat(long pos, float value) throws IOException
      Write a 32-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeFloatLE

      public void writeFloatLE(long pos, float value) throws IOException
      Write a 32-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeFloatBE

      public void writeFloatBE(long pos, float value) throws IOException
      Write a 32-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readFloat

      public float readFloat(long pos) throws IOException
      Read a 32-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readFloatLE

      public float readFloatLE(long pos) throws IOException
      Read a 32-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readFloatBE

      public float readFloatBE(long pos) throws IOException
      Read a 32-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeDouble

      public void writeDouble(long pos, double value) throws IOException
      Write a 64-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeDoubleLE

      public void writeDoubleLE(long pos, double value) throws IOException
      Write a 64-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • writeDoubleBE

      public void writeDoubleBE(long pos, double value) throws IOException
      Write a 64-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readDouble

      public double readDouble(long pos) throws IOException
      Read a 64-bit floating-point value using raw bit patterns at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readDoubleLE

      public double readDoubleLE(long pos) throws IOException
      Read a 64-bit floating-point value using raw bit patterns at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readDoubleBE

      public double readDoubleBE(long pos) throws IOException
      Read a 64-bit floating-point value using raw bit patterns at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeBoolean

      public void writeBoolean(long pos, boolean value) throws IOException
      Write a boolean value at the given file position without advancing the current position.
      Parameters:
      pos - the file position
      value - the value to write
      Throws:
      IOException - if an I/O error occurs
    • readBoolean

      public boolean readBoolean(long pos) throws IOException
      Read a boolean value at the given file position without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeChar

      public void writeChar(long pos, int value) throws IOException
      Write a 16-bit character value at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • writeCharLE

      public void writeCharLE(long pos, int value) throws IOException
      Write a 16-bit character value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • writeCharBE

      public void writeCharBE(long pos, int value) throws IOException
      Write a 16-bit character value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      value - the value (only the low 16 bits are used)
      Throws:
      IOException - if an I/O error occurs
    • readChar

      public char readChar(long pos) throws IOException
      Read a 16-bit character value at the given file position using the default byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readCharLE

      public char readCharLE(long pos) throws IOException
      Read a 16-bit character value at the given file position using little-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readCharBE

      public char readCharBE(long pos) throws IOException
      Read a 16-bit character value at the given file position using big-endian byte order without advancing the current position.
      Parameters:
      pos - the file position
      Returns:
      the value read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • read

      public int read(byte[] dest, int offset, int length) throws IOException
      Read bytes into the given array at the current position and advance.
      Parameters:
      dest - the destination array
      offset - the start offset in the array
      length - the maximum number of bytes to read
      Returns:
      the number of bytes actually read, or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(byte[] dest) throws IOException
      Read bytes into the given array at the current position and advance.
      Parameters:
      dest - the destination array
      Returns:
      the number of bytes actually read, or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • readFully

      public void readFully(byte[] dest, int offset, int length) throws IOException
      Read exactly length bytes at the current position and advance. If EOFException is thrown, the buffer may have been partially populated.
      Parameters:
      dest - the destination array
      offset - the start offset in the array
      length - the number of bytes to read
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readFully

      public void readFully(byte[] dest) throws IOException
      Read exactly dest.length bytes from the current position into the given array and advance.
      Parameters:
      dest - the destination array
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • write

      public void write(byte[] src, int offset, int length) throws IOException
      Write bytes from the given array at the current position and advance.
      Parameters:
      src - the source array
      offset - the start offset in the array
      length - the number of bytes to write
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(byte[] src) throws IOException
      Write all bytes from the given array to the current position and advance.
      Parameters:
      src - the source byte array
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(long pos, byte[] dest) throws IOException
      Read bytes at the given file position without changing the current position.
      Parameters:
      pos - the file position
      dest - the destination array
      Returns:
      the number of bytes actually read, or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(long pos, byte[] dest, int offset, int length) throws IOException
      Read bytes at the given file position without changing the current position.
      Parameters:
      pos - the file position
      dest - the destination array
      offset - the start offset in the array
      length - the maximum number of bytes to read
      Returns:
      the number of bytes actually read, or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(long pos, byte[] src, int offset, int length) throws IOException
      Write bytes at the given file position without changing the current position.
      Parameters:
      pos - the file position
      src - the source array
      offset - the start offset in the array
      length - the number of bytes to write
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(ByteBuffer dest) throws IOException
      Read into the given ByteBuffer at the current position and advance.
      Parameters:
      dest - the destination buffer
      Returns:
      the number of bytes read, or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • write

      public void write(ByteBuffer src) throws IOException
      Write from the given ByteBuffer at the current position and advance.
      Parameters:
      src - the source buffer
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(long pos, ByteBuffer dest) throws IOException
      Read into the given ByteBuffer at the given file position without changing the current position.
      Parameters:
      pos - the file position
      dest - the destination buffer
      Returns:
      the number of bytes read, or -1 at end-of-file
      Throws:
      IOException - if an I/O error occurs
    • write

      public int write(long pos, ByteBuffer src) throws IOException
      Write from the given ByteBuffer at the given file position without changing the current position.
      Parameters:
      pos - the file position
      src - the source buffer
      Returns:
      the number of bytes written
      Throws:
      IOException - if an I/O error occurs
    • writeZeroTerminatedString

      public void writeZeroTerminatedString(String s, Charset charset) throws IOException
      Write a string encoded with the given charset, followed by a zero byte, and advance.
      Parameters:
      s - the string to write
      charset - the charset to use for encoding
      Throws:
      IOException - if an I/O error occurs
    • writeZeroTerminatedString

      public void writeZeroTerminatedString(String s) throws IOException
      Write a UTF-8-encoded string followed by a zero byte and advance.
      Parameters:
      s - the string to write
      Throws:
      IOException - if an I/O error occurs
    • writeString

      public void writeString(String s, Charset charset) throws IOException
      Write a string encoded with the given charset (no terminator) and advance.
      Parameters:
      s - the string to write
      charset - the charset to use for encoding
      Throws:
      IOException - if an I/O error occurs
    • writeString

      public void writeString(String s) throws IOException
      Write a UTF-8-encoded string (no terminator) and advance.
      Parameters:
      s - the string to write
      Throws:
      IOException - if an I/O error occurs
    • readZeroTerminatedString

      public String readZeroTerminatedString(Charset charset) throws IOException
      Read a zero-terminated string using the given charset and advance past the terminator.
      Parameters:
      charset - the charset to use for decoding
      Returns:
      the string (not including the zero terminator)
      Throws:
      EOFException - if end-of-file is reached before a zero byte is found
      IOException - if an I/O error occurs
    • readZeroTerminatedString

      public String readZeroTerminatedString() throws IOException
      Read a zero-terminated UTF-8 string and advance past the terminator.
      Returns:
      the string
      Throws:
      EOFException - if end-of-file is reached before a zero byte is found
      IOException - if an I/O error occurs
    • readString

      public String readString(int byteLength, Charset charset) throws IOException
      Read a fixed number of bytes and decode as a string using the given charset.
      Parameters:
      byteLength - the number of bytes to read
      charset - the charset to use for decoding
      Returns:
      the decoded string
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • readString

      public String readString(int byteLength) throws IOException
      Read a fixed number of bytes and decode as a UTF-8 string.
      Parameters:
      byteLength - the number of bytes to read
      Returns:
      the decoded string
      Throws:
      EOFException - if end-of-file is reached before all bytes are read
      IOException - if an I/O error occurs
    • writeZeros

      public void writeZeros(long count) throws IOException
      Write the given number of zero bytes at the current position and advance.
      Parameters:
      count - the number of zero bytes to write
      Throws:
      IOException - if an I/O error occurs
    • writeZeros

      public void writeZeros(long pos, long count) throws IOException
      Write zero bytes at the given file position without changing the current position.
      Parameters:
      pos - the file position
      count - the number of zero bytes to write
      Throws:
      IOException - if an I/O error occurs
    • transferTo

      public long transferTo(OutputStream out) throws IOException
      Transfer all remaining bytes from the current position to the given output stream.
      Parameters:
      out - the output stream
      Returns:
      the number of bytes transferred
      Throws:
      IOException - if an I/O error occurs
    • transferTo

      public long transferTo(OutputStream out, long length) throws IOException
      Transfer up to length bytes from the current position to the given output stream.
      Parameters:
      out - the output stream
      length - the maximum number of bytes to transfer
      Returns:
      the number of bytes transferred
      Throws:
      IOException - if an I/O error occurs
    • transferTo

      public long transferTo(long pos, OutputStream out, long length) throws IOException
      Transfer bytes from the given file position to the output stream without changing the current position.
      Parameters:
      pos - the file position to read from
      out - the output stream
      length - the number of bytes to transfer
      Returns:
      the number of bytes transferred
      Throws:
      IOException - if an I/O error occurs
    • transferFrom

      public long transferFrom(InputStream in) throws IOException
      Transfer all bytes from the given input stream to the current position.
      Parameters:
      in - the input stream
      Returns:
      the number of bytes transferred
      Throws:
      IOException - if an I/O error occurs
    • transferFrom

      public long transferFrom(InputStream in, long length) throws IOException
      Transfer up to length bytes from the given input stream to the current position.
      Parameters:
      in - the input stream
      length - the maximum number of bytes to transfer
      Returns:
      the number of bytes transferred
      Throws:
      IOException - if an I/O error occurs
    • transferFrom

      public long transferFrom(long pos, InputStream in, long length) throws IOException
      Transfer bytes from the given input stream to the given file position without changing the current position.
      Parameters:
      pos - the file position to write to
      in - the input stream
      length - the maximum number of bytes to transfer
      Returns:
      the number of bytes transferred
      Throws:
      IOException - if an I/O error occurs
    • flush

      public void flush() throws IOException
      Flush any buffered data to the file.
      Specified by:
      flush in interface Flushable
      Throws:
      IOException - if an I/O error occurs
    • close

      public void close() throws IOException
      Flush any buffered data and close this file. Subsequent operations (except further calls to close()) will throw IOException.

      For nested views, this method flushes buffered data, advances the parent's position past the nested data, unlocks the parent for further use, and then invokes the close action (if any). The close action runs after the parent is unlocked, so it may read and write the parent freely. The underlying file is not closed; the root instance owns the file handle.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an I/O error occurs
      IllegalStateException - if a nested child view is still active
    • inputStream

      Returns a cached FileInputStream view of this file.

      The returned stream also implements DataInput (with big-endian semantics). Calling close() on the returned stream is a no-op.

      Returns:
      a cached FileInputStream view of this file
      Throws:
      IllegalStateException - if this file was not opened for reading
    • outputStream

      Returns a cached FileOutputStream view of this file.

      The returned stream also implements DataOutput (with big-endian semantics). Calling close() on the returned stream is a no-op.

      Returns:
      a cached FileOutputStream view of this file
      Throws:
      IllegalStateException - if this file was not opened for writing
    • channel

      Returns a cached FileChannel view of this file.

      All read/write/position operations on the returned channel delegate to this BufferedFile, maintaining buffer consistency. Calling close() on the returned channel is a no-op.

      Returns:
      a cached FileChannel view of this file