net.metanotion.io

## Class RAIFile

- java.lang.Object
- - net.metanotion.io.RAIFile

- All Implemented Interfaces:
    DataInput, DataOutput, RandomAccessInterface

      public class RAIFile
      extends Object
      implements RandomAccessInterface, DataInput, DataOutput

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RAIFile(File file, boolean read, boolean write)`
    `RAIFile(RandomAccessFile file)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `long` | `getFilePointer()`
    `long` | `length()`
    `int` | `read()`
    `int` | `read(byte[] b)`
    `int` | `read(byte[] b, int off, int len)`
    `boolean` | `readBoolean()`
    `byte` | `readByte()`
    `char` | `readChar()`
    `double` | `readDouble()`
    `float` | `readFloat()`
    `void` | `readFully(byte[] b)`
    `void` | `readFully(byte[] b, int off, int len)`
    `int` | `readInt()`
    `String` | `readLine()`
    `long` | `readLong()`
    `short` | `readShort()`
    `int` | `readUnsignedByte()`
    `int` | `readUnsignedInt()` I2P
    `int` | `readUnsignedShort()`
    `String` | `readUTF()` Read a UTF encoded string I would delegate here.
    `void` | `seek(long pos)`
    `void` | `setLength(long newLength)`
    `int` | `skipBytes(int n)`
    `void` | `write(byte[] b)`
    `void` | `write(byte[] b, int off, int len)`
    `void` | `write(int b)`
    `void` | `writeBoolean(boolean v)`
    `void` | `writeByte(int v)`
    `void` | `writeBytes(String s)`
    `void` | `writeChar(int v)`
    `void` | `writeChars(String s)`
    `void` | `writeDouble(double v)`
    `void` | `writeFloat(float v)`
    `void` | `writeInt(int v)`
    `void` | `writeLong(long v)`
    `void` | `writeShort(int v)`
    `void` | `writeUTF(String str)` Write a UTF encoded string I would delegate here.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RAIFile

          public RAIFile(RandomAccessFile file)
                  throws FileNotFoundException

      Throws:
        `FileNotFoundException`

    - #### RAIFile

          public RAIFile(File file,
                 boolean read,
                 boolean write)
                  throws FileNotFoundException

      Throws:
        `FileNotFoundException`

  - ### Method Detail

    - #### getFilePointer

          public long getFilePointer()
                              throws IOException

      Specified by:
        `getFilePointer` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### length

          public long length()
                      throws IOException

      Specified by:
        `length` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### read

          public int read()
                   throws IOException

      Specified by:
        `read` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### read

          public int read(byte[] b)
                   throws IOException

      Specified by:
        `read` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### read

          public int read(byte[] b,
                 int off,
                 int len)
                   throws IOException

      Specified by:
        `read` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### seek

          public void seek(long pos)
                    throws IOException

      Specified by:
        `seek` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### setLength

          public void setLength(long newLength)
                         throws IOException

      Specified by:
        `setLength` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readBoolean

          public boolean readBoolean()
                              throws IOException

      Specified by:
        `readBoolean` in interface `DataInput`
      Specified by:
        `readBoolean` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readByte

          public byte readByte()
                        throws IOException

      Specified by:
        `readByte` in interface `DataInput`
      Specified by:
        `readByte` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readChar

          public char readChar()
                        throws IOException

      Specified by:
        `readChar` in interface `DataInput`
      Specified by:
        `readChar` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readDouble

          public double readDouble()
                            throws IOException

      Specified by:
        `readDouble` in interface `DataInput`
      Specified by:
        `readDouble` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readFloat

          public float readFloat()
                          throws IOException

      Specified by:
        `readFloat` in interface `DataInput`
      Specified by:
        `readFloat` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readFully

          public void readFully(byte[] b)
                         throws IOException

      Specified by:
        `readFully` in interface `DataInput`
      Specified by:
        `readFully` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readFully

          public void readFully(byte[] b,
                       int off,
                       int len)
                         throws IOException

      Specified by:
        `readFully` in interface `DataInput`
      Specified by:
        `readFully` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readInt

          public int readInt()
                      throws IOException

      Specified by:
        `readInt` in interface `DataInput`
      Specified by:
        `readInt` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readLine

          public String readLine()
                          throws IOException

      Specified by:
        `readLine` in interface `DataInput`
      Specified by:
        `readLine` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readLong

          public long readLong()
                        throws IOException

      Specified by:
        `readLong` in interface `DataInput`
      Specified by:
        `readLong` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readShort

          public short readShort()
                          throws IOException

      Specified by:
        `readShort` in interface `DataInput`
      Specified by:
        `readShort` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readUnsignedByte

          public int readUnsignedByte()
                               throws IOException

      Specified by:
        `readUnsignedByte` in interface `DataInput`
      Specified by:
        `readUnsignedByte` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readUnsignedShort

          public int readUnsignedShort()
                                throws IOException

      Specified by:
        `readUnsignedShort` in interface `DataInput`
      Specified by:
        `readUnsignedShort` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### readUnsignedInt

          public int readUnsignedInt()
                              throws IOException

      I2P
      Specified by:
        `readUnsignedInt` in interface `RandomAccessInterface`
      Throws:
        `IOException` - if the read value is negative

    - #### readUTF

          public String readUTF()
                         throws IOException

      Read a UTF encoded string I would delegate here. But Java's read/writeUTF combo suck. A signed 2 byte length is not enough. This reads a 4 byte length. The upper byte MUST be zero, if its not, then its not this method and has used an extensible length encoding. This is followed by the bytes of the UTF encoded string, as returned by String.getBytes("UTF-8");
      Specified by:
        `readUTF` in interface `DataInput`
      Specified by:
        `readUTF` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### skipBytes

          public int skipBytes(int n)
                        throws IOException

      Specified by:
        `skipBytes` in interface `DataInput`
      Specified by:
        `skipBytes` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### write

          public void write(int b)
                     throws IOException

      Specified by:
        `write` in interface `DataOutput`
      Specified by:
        `write` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### write

          public void write(byte[] b)
                     throws IOException

      Specified by:
        `write` in interface `DataOutput`
      Specified by:
        `write` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### write

          public void write(byte[] b,
                   int off,
                   int len)
                     throws IOException

      Specified by:
        `write` in interface `DataOutput`
      Specified by:
        `write` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeBoolean

          public void writeBoolean(boolean v)
                            throws IOException

      Specified by:
        `writeBoolean` in interface `DataOutput`
      Specified by:
        `writeBoolean` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeByte

          public void writeByte(int v)
                         throws IOException

      Specified by:
        `writeByte` in interface `DataOutput`
      Specified by:
        `writeByte` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeShort

          public void writeShort(int v)
                          throws IOException

      Specified by:
        `writeShort` in interface `DataOutput`
      Specified by:
        `writeShort` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeChar

          public void writeChar(int v)
                         throws IOException

      Specified by:
        `writeChar` in interface `DataOutput`
      Specified by:
        `writeChar` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeInt

          public void writeInt(int v)
                        throws IOException

      Specified by:
        `writeInt` in interface `DataOutput`
      Specified by:
        `writeInt` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeLong

          public void writeLong(long v)
                         throws IOException

      Specified by:
        `writeLong` in interface `DataOutput`
      Specified by:
        `writeLong` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeFloat

          public void writeFloat(float v)
                          throws IOException

      Specified by:
        `writeFloat` in interface `DataOutput`
      Specified by:
        `writeFloat` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeDouble

          public void writeDouble(double v)
                           throws IOException

      Specified by:
        `writeDouble` in interface `DataOutput`
      Specified by:
        `writeDouble` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeBytes

          public void writeBytes(String s)
                          throws IOException

      Specified by:
        `writeBytes` in interface `DataOutput`
      Specified by:
        `writeBytes` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeChars

          public void writeChars(String s)
                          throws IOException

      Specified by:
        `writeChars` in interface `DataOutput`
      Specified by:
        `writeChars` in interface `RandomAccessInterface`
      Throws:
        `IOException`

    - #### writeUTF

          public void writeUTF(String str)
                        throws IOException

      Write a UTF encoded string I would delegate here. But Java's read/writeUTF combo suck. A signed 2 byte length is not enough. This writes a 4 byte length. The upper byte MUST be zero, if its not, then its not this method and has used an extensible length encoding. This is followed by the bytes of the UTF encoded string, as returned by String.getBytes("UTF-8");
      Specified by:
        `writeUTF` in interface `DataOutput`
      Specified by:
        `writeUTF` in interface `RandomAccessInterface`
      Throws:
        `IOException`