java.lang.Object
net.metanotion.io.RAIFile
All Implemented Interfaces:
Closeable, DataInput, DataOutput, AutoCloseable, RandomAccessInterface

public class RAIFileextends Object implements RandomAccessInterface, DataInput, DataOutput
Implementation of RandomAccessInterface using RandomAccessFile. Provides file-based random access with DataInput and DataOutput capabilities.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final RandomAccessFile
    The access this class forwards to.
    private final File
    The file on disk.
    private final boolean
    True if the file was opened for reading.
    private final boolean
    True if the file was opened for writing.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RAIFile(File file, boolean read, boolean write)
    Opens the file, deriving the open mode from the flags.
    Wraps an open file, treating it as readable and writable.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    boolean
    Is the file writable? (I2P) Only valid if the File constructor was used, not the RAF constructor
    void
    Closes the file.
    long
    Current read/write position.
    long
    File length in bytes.
    int
    Reads one byte and advances the file pointer past it.
    int
    read(byte[] b)
    Reads bytes into b and advances the file pointer past them.
    int
    read(byte[] b, int off, int len)
    Reads bytes into b at off and advances the file pointer past them.
    boolean
    Reads a single byte, reporting it as a boolean.
    byte
    Reads one byte as a signed value.
    char
    Reads two bytes as a big-endian char.
    double
    Reads eight bytes as a big-endian double.
    float
    Reads four bytes as a big-endian float.
    void
    readFully(byte[] b)
    Fills b, failing unless every byte of it is read.
    void
    readFully(byte[] b, int off, int len)
    Fills len bytes of b at off, failing unless all are read.
    int
    Reads four bytes as a big-endian int.
    Reads bytes up to a line terminator, discarding the terminator.
    long
    Reads eight bytes as a big-endian long.
    short
    Reads two bytes as a big-endian short.
    int
    Reads one byte, widening it to an unsigned int.
    int
    Reads an unsigned 32-bit integer from the file.
    int
    Reads two bytes, widening them to an unsigned int.
    Read a UTF encoded string with 4-byte length prefix.
    void
    seek(long pos)
    Moves the file pointer to an absolute offset.
    void
    setLength(long newLength)
    Truncates or extends the file to the given size.
    int
    skipBytes(int n)
    Advances the file pointer without reading the bytes skipped.
    File name for debugging.
    void
    write(byte[] b)
    Writes every byte of b.
    void
    write(byte[] b, int off, int len)
    Writes len bytes from b, starting at off.
    void
    write(int b)
    Writes the low eight bits of b.
    void
    writeBoolean(boolean v)
    Writes a single byte holding 1 for true, 0 for false.
    void
    writeByte(int v)
    Writes the low eight bits of v.
    void
    Writes the low byte of each character of s.
    void
    writeChar(int v)
    Writes the low sixteen bits of v as a big-endian char.
    void
    Writes each character of s as two big-endian bytes.
    void
    writeDouble(double v)
    Writes v as eight big-endian bytes.
    void
    writeFloat(float v)
    Writes v as four big-endian bytes.
    void
    writeInt(int v)
    Writes v as four big-endian bytes.
    void
    writeLong(long v)
    Writes v as eight big-endian bytes.
    void
    writeShort(int v)
    Writes the low sixteen bits of v as a big-endian short.
    void
    Write a UTF encoded string with 4-byte length prefix.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait