Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindprod.ledatastream
Class LERandomAccessFile

    java.lang.Object
      com.mindprod.ledatastream.LERandomAccessFile

All Implemented Interfaces:
  java.io.DataInput, java.io.DataOutput

    public final class LERandomAccessFile

extends java.lang.Object
implements java.io.DataInput, java.io.DataOutput

Little-endian version of RandomAccessFile.

Since:
  1998
Version:
  1.8 2007-05-24
Author:
  Roedy Green, Canadian Mind Products

Field Summary
`protected java.io.RandomAccessFile` | `raf` to get at the big-endian methods of RandomAccessFile .
`protected byte[]` | `work` work array for buffering input/output.

Constructor Summary
`LERandomAccessFile(java.io.File file, java.lang.String rw)` constructor.
`LERandomAccessFile(java.lang.String file, java.lang.String rw)` constructors.

Method Summary
`void` | `close()` close the file.
`java.io.FileDescriptor` | `getFD()` Get file descriptor.
`long` | `getFilePointer()` get position of marker in the file.
`long` | `length()` get length of the file.
`int` | `read()` ready one unsigned byte.
`int` | `read(byte[] ba)` read an array of bytes.
`int` | `read(byte[] ba, int off, int len)` Read a byte array.
`boolean` | `readBoolean()` OK, reads only only 1 byte boolean.
`byte` | `readByte()` read byte.
`char` | `readChar()` Read a char.
`double` | `readDouble()` read a double.
`float` | `readFloat()` read a float.
`void` | `readFully(byte[] ba)` Read a full array.
`void` | `readFully(byte[] ba, int off, int len)` read an array of bytes until the count is satisfied.
`int` | `readInt()` read signed little endian 32-bit int.
`java.lang.String` | `readLine()` Read a line.
`long` | `readLong()` Read a long, 64 bits.
`short` | `readShort()` Read a short, 16 bits.
`int` | `readUnsignedByte()` return an unsigned byte.
`int` | `readUnsignedShort()` Read an unsigned short, 16 bits.
`java.lang.String` | `readUTF()` Read a counted UTF-8 string.
`void` | `seek(long pos)` seek to a place in the file
`int` | `skipBytes(int n)` Skip over bytes.
`void` | `write(byte[] ba)` Write an array of bytes.
`void` | `write(byte[] ba, int off, int len)` Write part of an array of bytes.
`void` | `write(int ib)` Write a byte.
`void` | `writeBoolean(boolean v)` write a boolean as one byte.
`void` | `writeByte(int v)` Write a byte.
`void` | `writeBytes(java.lang.String s)` Write bytes from a String.
`void` | `writeChar(int v)` Write a char.
`void` | `writeChars(java.lang.String s)` Write a string, even though method called writeChars.
`void` | `writeDouble(double v)` Write a double.
`void` | `writeFloat(float v)` Write a float.
`void` | `writeInt(int v)` write an int, 32-bits.
`void` | `writeLong(long v)` Write i long, 64 bits.
`void` | `writeShort(int v)` Write an signed short even though parameter is an int.
`void` | `writeUTF(java.lang.String s)` Write a counted UTF string.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### raf

    protected java.io.RandomAccessFile raf

  to get at the big-endian methods of RandomAccessFile .

### work

    protected byte[] work

  work array for buffering input/output.

Constructor Detail

### LERandomAccessFile

    public LERandomAccessFile(java.io.File file,
                              java.lang.String rw)
                       throws java.io.FileNotFoundException

  constructor.

  Parameters:
    `file` - file to read/write.
    `rw` - like `RandomAccessFile` where "r" for read "rw" for read and write, "rws" for read-write sync, and "rwd" for read-write dsync. Sync ensures the physical I/O has completed befor the method returns.
  Throws:
    `java.io.FileNotFoundException` - if open fails.

### LERandomAccessFile

    public LERandomAccessFile(java.lang.String file,
                              java.lang.String rw)
                       throws java.io.FileNotFoundException

  constructors.

  Parameters:
    `file` - name of file.
    `rw` - string "r" or "rw" depending on read or read/write.
  Throws:
    `java.io.FileNotFoundException` - if open fails.

Method Detail

### close

    public final void close()
                     throws java.io.IOException

  close the file.

  Throws:
    `java.io.IOException` - if close fails.

### getFD

    public final java.io.FileDescriptor getFD()
                                       throws java.io.IOException

  Get file descriptor.

  Returns:
    file descriptor (handle to open file)
  Throws:
    `java.io.IOException` - if get fails.

### getFilePointer

    public final long getFilePointer()
                              throws java.io.IOException

  get position of marker in the file.

  Returns:
    offset where we are in the file.
  Throws:
    `java.io.IOException` - if get fails.

### length

    public final long length()
                      throws java.io.IOException

  get length of the file.

  Returns:
    length in bytes, note value is a long.
  Throws:
    `java.io.IOException` - if get fails.

### read

    public final int read()
                   throws java.io.IOException

  ready one unsigned byte.

  Returns:
    unsigned byte read.
  Throws:
    `java.io.IOException` - if read fails.

### read

    public final int read(byte[] ba)
                   throws java.io.IOException

  read an array of bytes.

  Parameters:
    `ba` - byte array to accept the bytes.
  Returns:
    how many bytes actually read.
  Throws:
    `java.io.IOException` - if read fails.

### read

    public final int read(byte[] ba,
                          int off,
                          int len)
                   throws java.io.IOException

  Read a byte array.

  Parameters:
    `ba` - byte array to accept teh bytes.
    `off` - offset into the array to place the bytes, not offset in file.
    `len` - how many bytes to read.
  Returns:
    how many bytes actually read.
  Throws:
    `java.io.IOException` - if read fails.

### readBoolean

    public final boolean readBoolean()
                              throws java.io.IOException

  OK, reads only only 1 byte boolean.

  Specified by:
    `readBoolean` in interface `java.io.DataInput`
  Returns:
    true or false.
  Throws:
    `java.io.IOException` - if read fails.

### readByte

    public final byte readByte()
                        throws java.io.IOException

  read byte.

  Specified by:
    `readByte` in interface `java.io.DataInput`
  Returns:
    byte read.
  Throws:
    `java.io.IOException` - if read fails.

### readChar

    public final char readChar()
                        throws java.io.IOException

  Read a char. like RandomAcessFile.readChar except little endian.

  Specified by:
    `readChar` in interface `java.io.DataInput`
  Returns:
    char read.
  Throws:
    `java.io.IOException` - if read fails.

### readDouble

    public final double readDouble()
                            throws java.io.IOException

  read a double. like RandomAcessFile.readDouble except little endian.

  Specified by:
    `readDouble` in interface `java.io.DataInput`
  Returns:
    the double read.
  Throws:
    `java.io.IOException` - if read fails.

### readFloat

    public final float readFloat()
                          throws java.io.IOException

  read a float. like RandomAcessFile.readFloat except little endian.

  Specified by:
    `readFloat` in interface `java.io.DataInput`
  Returns:
    float read.
  Throws:
    `java.io.IOException` - if read fails.

### readFully

    public final void readFully(byte[] ba)
                         throws java.io.IOException

  Read a full array.

  Specified by:
    `readFully` in interface `java.io.DataInput`
  Parameters:
    `ba` - the array to hold the results.
  Throws:
    `java.io.IOException` - if read fails.

### readFully

    public final void readFully(byte[] ba,
                                int off,
                                int len)
                         throws java.io.IOException

  read an array of bytes until the count is satisfied.

  Specified by:
    `readFully` in interface `java.io.DataInput`
  Parameters:
    `ba` - the array to hold the results.
    `off` - offset.
    `len` - count of bytes to read.
  Throws:
    `java.io.IOException` - if read fails.

### readInt

    public final int readInt()
                      throws java.io.IOException

  read signed little endian 32-bit int.

  Specified by:
    `readInt` in interface `java.io.DataInput`
  Returns:
    signed int
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `except little endian.`

### readLine

    public final java.lang.String readLine()
                                    throws java.io.IOException

  Read a line.

  Specified by:
    `readLine` in interface `java.io.DataInput`
  Returns:
    line read.
  Throws:
    `java.io.IOException` - if read fails.

### readLong

    public final long readLong()
                        throws java.io.IOException

  Read a long, 64 bits.

  Specified by:
    `readLong` in interface `java.io.DataInput`
  Returns:
    long read. like RandomAcessFile.readLong except little endian.
  Throws:
    `java.io.IOException` - if read fails.

### readShort

    public final short readShort()
                          throws java.io.IOException

  Read a short, 16 bits.

  Specified by:
    `readShort` in interface `java.io.DataInput`
  Returns:
    short read. like RandomAcessFile.readShort except little endian.
  Throws:
    `java.io.IOException` - if read fails.

### readUTF

    public final java.lang.String readUTF()
                                   throws java.io.IOException

  Read a counted UTF-8 string.

  Specified by:
    `readUTF` in interface `java.io.DataInput`
  Returns:
    string read.
  Throws:
    `java.io.IOException` - if read fails.

### readUnsignedByte

    public final int readUnsignedByte()
                               throws java.io.IOException

  return an unsigned byte. Noote: returns an int, even though says Byte.

  Specified by:
    `readUnsignedByte` in interface `java.io.DataInput`
  Returns:
    the byte read.
  Throws:
    `java.io.IOException` - if read fails.

### readUnsignedShort

    public final int readUnsignedShort()
                                throws java.io.IOException

  Read an unsigned short, 16 bits. Like RandomAcessFile.readUnsignedShort except little endian. Note, returns int even though it reads a short.

  Specified by:
    `readUnsignedShort` in interface `java.io.DataInput`
  Returns:
    little-endian unsigned short, as an int.
  Throws:
    `java.io.IOException` - if read fails.

### seek

    public final void seek(long pos)
                    throws java.io.IOException

  seek to a place in the file

  Parameters:
    `pos` - 0-based offset to seek to.
  Throws:
    `java.io.IOException` - if read fails.

### skipBytes

    public final int skipBytes(int n)
                        throws java.io.IOException

  Skip over bytes.

  Specified by:
    `skipBytes` in interface `java.io.DataInput`
  Parameters:
    `n` - number of bytes to skip over.
  Returns:
    the actual number of bytes skipped.
  Throws:
    `java.io.IOException` - if read fails.

### write

    public final void write(int ib)
                     throws java.io.IOException

  Write a byte. Only writes one byte even though says int.

  Specified by:
    `write` in interface `java.io.DataOutput`
  Parameters:
    `ib` - byte to write.
  Throws:
    `java.io.IOException` - if read fails.

### write

    public final void write(byte[] ba)
                     throws java.io.IOException

  Write an array of bytes.

  Specified by:
    `write` in interface `java.io.DataOutput`
  Parameters:
    `ba` - array to write.
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `DataOutput.write(byte[])`

### write

    public final void write(byte[] ba,
                            int off,
                            int len)
                     throws java.io.IOException

  Write part of an array of bytes.

  Specified by:
    `write` in interface `java.io.DataOutput`
  Parameters:
    `ba` - array to write.
    `off` - offset
    `len` - count of bytes to write.
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `DataOutput.write(byte[],int,int)`

### writeBoolean

    public final void writeBoolean(boolean v)
                            throws java.io.IOException

  write a boolean as one byte.

  Specified by:
    `writeBoolean` in interface `java.io.DataOutput`
  Parameters:
    `v` - boolean to write.
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `DataOutput.writeBoolean(boolean)`

### writeByte

    public final void writeByte(int v)
                         throws java.io.IOException

  Write a byte. Note param is an int though only a byte is written.

  Specified by:
    `writeByte` in interface `java.io.DataOutput`
  Parameters:
    `v` - byte to write.
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `DataOutput.writeByte(int)`

### writeBytes

    public final void writeBytes(java.lang.String s)
                          throws java.io.IOException

  Write bytes from a String.

  Specified by:
    `writeBytes` in interface `java.io.DataOutput`
  Parameters:
    `s` - string source of the bytes.
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `DataOutput.writeBytes(java.lang.String)`

### writeChar

    public final void writeChar(int v)
                         throws java.io.IOException

  Write a char. note param is an int though writes a char.

  Specified by:
    `writeChar` in interface `java.io.DataOutput`
  Parameters:
    `v` - char to write. like RandomAcessFile.writeChar. Note the parm is an int even though this as a writeChar
  Throws:
    `java.io.IOException` - if read fails.

### writeChars

    public final void writeChars(java.lang.String s)
                          throws java.io.IOException

  Write a string, even though method called writeChars. like RandomAcessFile.writeChars, has to flip each char.

  Specified by:
    `writeChars` in interface `java.io.DataOutput`
  Parameters:
    `s` - Strinhg to write.
  Throws:
    `java.io.IOException` - if read fails.

### writeDouble

    public final void writeDouble(double v)
                           throws java.io.IOException

  Write a double. Like RandomAcessFile.writeDouble.

  Specified by:
    `writeDouble` in interface `java.io.DataOutput`
  Parameters:
    `v` - double to write.
  Throws:
    `java.io.IOException` - if read fails.

### writeFloat

    public final void writeFloat(float v)
                          throws java.io.IOException

  Write a float. Like RandomAcessFile.writeFloat.

  Specified by:
    `writeFloat` in interface `java.io.DataOutput`
  Parameters:
    `v` - float to write.
  Throws:
    `java.io.IOException` - if read fails.

### writeInt

    public final void writeInt(int v)
                        throws java.io.IOException

  write an int, 32-bits. Like RandomAcessFile.writeInt.

  Specified by:
    `writeInt` in interface `java.io.DataOutput`
  Parameters:
    `v` - int to write.
  Throws:
    `java.io.IOException` - if read fails.

### writeLong

    public final void writeLong(long v)
                         throws java.io.IOException

  Write i long, 64 bits. Like java.io.RandomAccessFile.writeLong.

  Specified by:
    `writeLong` in interface `java.io.DataOutput`
  Parameters:
    `v` - long write.
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `RandomAccessFile.writeLong(long)`

### writeShort

    public final void writeShort(int v)
                          throws java.io.IOException

  Write an signed short even though parameter is an int. Like java.io.RandomAcessFile#writeShort. also acts as a writeUnsignedShort.

  Specified by:
    `writeShort` in interface `java.io.DataOutput`
  Parameters:
    `v` - signed number to write
  Throws:
    `java.io.IOException` - if read fails.

### writeUTF

    public final void writeUTF(java.lang.String s)
                        throws java.io.IOException

  Write a counted UTF string.

  Specified by:
    `writeUTF` in interface `java.io.DataOutput`
  Parameters:
    `s` - String to write.
  Throws:
    `java.io.IOException` - if read fails.
  See Also:
    `DataOutput.writeUTF(java.lang.String)`

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD