gov.nist.microanalysis.EPQTools
Class EndianRandomAccessFile

java.lang.Object
  extended by gov.nist.microanalysis.EPQTools.EndianRandomAccessFile
All Implemented Interfaces:
java.io.DataInput, java.io.DataOutput

public class EndianRandomAccessFile
extends java.lang.Object
implements java.io.DataInput, java.io.DataOutput

A class that implements DataInput and DataOutput for binary files in either little-endian or big-endian format.

Copyright: Pursuant to title 17 Section 105 of the United States Code this software is not subject to copyright protection and is in the public domain

Institution: National Institute of Standards and Technology

Version:
1.0
Author:
Nicholas

Field Summary
static java.lang.String BigEndian
          BigEndian - Specifies that Big Endian ordering should be used.
static java.lang.String LittleEndian
          LittleEndian - Specifies that Little Endian ordering should be used.
 
Constructor Summary
EndianRandomAccessFile(java.io.File f, java.lang.String rw, java.lang.String endian)
          EndianRandomAccessFile - Similar to the RandomAccessFile constructors except for the final argument.
EndianRandomAccessFile(java.lang.String f, java.lang.String rw, java.lang.String endian)
          EndianRandomAccessFile - Similar to the RandomAccessFile constructors except for the final argument.
 
Method Summary
 void close()
          like RandomAcessFile.close
 java.io.FileDescriptor getFD()
          like RandomAcessFile.getFD().
 long getFilePointer()
          like RandomAcessFile.getFilePointer()
 long length()
          like RandomAcessFile.length()
 int read()
          like RandomAcessFile.read
 int read(byte[] b)
          like RandomAcessFile.read
 int read(byte[] b, int off, int len)
          like RandomAcessFile.read(...)
 boolean readBoolean()
          like RandomAcessFile.readBoolean
 byte readByte()
          like RandomAcessFile.readByte
 char readChar()
          like RandomAcessFile.readChar except endianess depends upon constructor
 double readDouble()
          like RandomAcessFile.readDouble except endianess depends upon constructor
 float readFloat()
          like RandomAcessFile.readFloat except endianess depends upon constructor
 void readFully(byte[] b)
          like RandomAcessFile.readFully
 void readFully(byte[] b, int off, int len)
          like RandomAcessFile.readFully
 int readInt()
          like RandomAcessFile.readInt except endianess depends upon constructor
 java.lang.String readLine()
          like RandomAcessFile.readLine
 long readLong()
          like RandomAcessFile.readLong except endianess depends upon constructor
 short readShort()
          like RandomAcessFile.readShort except endianess depends upon constructor.
 int readUnsignedByte()
          like RandomAcessFile.readUnsignedByte
 long readUnsignedInt()
          like RandomAcessFile.readUnsignedShort except endianess depends upon constructor Note, returns long even though it reads an int.
 int readUnsignedShort()
          like RandomAcessFile.readUnsignedShort except endianess depends upon constructor Note, returns int even though it reads a short.
 java.lang.String readUTF()
          like RandomAcessFile.readUTF
 void seek(long pos)
          like RandomAcessFile.seek
 int skipBytes(int n)
          like RandomAcessFile.skipBytes
 void write(byte[] b)
          like RandomAcessFile.write
 void write(byte[] b, int off, int len)
          like RandomAcessFile.write
 void write(int b)
          like RandomAcessFile.write
 void writeBoolean(boolean v)
          like RandomAcessFile.writeBoolean
 void writeByte(int v)
          like RandomAcessFile.writeByte
 void writeBytes(java.lang.String s)
          like RandomAcessFile.writeBytes
 void writeChar(int v)
          like RandomAcessFile.writeChar.
 void writeChars(java.lang.String s)
          like RandomAcessFile.writeChars.
 void writeDouble(double v)
          like RandomAcessFile.writeDouble.
 void writeFloat(float v)
          like RandomAcessFile.writeFloat.
 void writeInt(int v)
          like RandomAcessFile.writeInt.
 void writeLong(long v)
          like RandomAcessFile.writeLong.
 void writeShort(int v)
          like RandomAcessFile.writeShort.
 void writeUTF(java.lang.String str)
          like RandomAcessFile.writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LittleEndian

public static final java.lang.String LittleEndian
LittleEndian - Specifies that Little Endian ordering should be used.

See Also:
Constant Field Values

BigEndian

public static final java.lang.String BigEndian
BigEndian - Specifies that Big Endian ordering should be used.

See Also:
Constant Field Values
Constructor Detail

EndianRandomAccessFile

public EndianRandomAccessFile(java.lang.String f,
                              java.lang.String rw,
                              java.lang.String endian)
                       throws java.io.IOException
EndianRandomAccessFile - Similar to the RandomAccessFile constructors except for the final argument.

Parameters:
f - String
rw - String As in RandomAccessFile mode "r", "rw", "rws", "rwd"
endian - String - One of EndianRandomAccessFile.LittleEndian or EndianRandomAccessFile.BigEndian
Throws:
java.io.IOException

EndianRandomAccessFile

public EndianRandomAccessFile(java.io.File f,
                              java.lang.String rw,
                              java.lang.String endian)
                       throws java.io.IOException
EndianRandomAccessFile - Similar to the RandomAccessFile constructors except for the final argument.

Parameters:
f - File
rw - String As in RandomAccessFile mode "r", "rw", "rws", "rwd"
endian - String - One of EndianRandomAccessFile.LittleEndian or EndianRandomAccessFile.BigEndian
Throws:
java.io.IOException
Method Detail

readShort

public final short readShort()
                      throws java.io.IOException
like RandomAcessFile.readShort except endianess depends upon constructor.

Specified by:
readShort in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedShort

public final int readUnsignedShort()
                            throws java.io.IOException
like RandomAcessFile.readUnsignedShort except endianess depends upon constructor Note, returns int even though it reads a short.

Specified by:
readUnsignedShort in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedInt

public final long readUnsignedInt()
                           throws java.io.IOException
like RandomAcessFile.readUnsignedShort except endianess depends upon constructor Note, returns long even though it reads an int.

Throws:
java.io.IOException

readChar

public final char readChar()
                    throws java.io.IOException
like RandomAcessFile.readChar except endianess depends upon constructor

Specified by:
readChar in interface java.io.DataInput
Throws:
java.io.IOException

readInt

public final int readInt()
                  throws java.io.IOException
like RandomAcessFile.readInt except endianess depends upon constructor

Specified by:
readInt in interface java.io.DataInput
Throws:
java.io.IOException

readLong

public final long readLong()
                    throws java.io.IOException
like RandomAcessFile.readLong except endianess depends upon constructor

Specified by:
readLong in interface java.io.DataInput
Throws:
java.io.IOException

readFloat

public final float readFloat()
                      throws java.io.IOException
like RandomAcessFile.readFloat except endianess depends upon constructor

Specified by:
readFloat in interface java.io.DataInput
Throws:
java.io.IOException

readDouble

public final double readDouble()
                        throws java.io.IOException
like RandomAcessFile.readDouble except endianess depends upon constructor

Specified by:
readDouble in interface java.io.DataInput
Throws:
java.io.IOException

writeShort

public final void writeShort(int v)
                      throws java.io.IOException
like RandomAcessFile.writeShort. also acts as a writeUnsignedShort

Specified by:
writeShort in interface java.io.DataOutput
Throws:
java.io.IOException

writeChar

public final void writeChar(int v)
                     throws java.io.IOException
like RandomAcessFile.writeChar. Note the parm is an int even though this as a writeChar

Specified by:
writeChar in interface java.io.DataOutput
Throws:
java.io.IOException

writeInt

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

Specified by:
writeInt in interface java.io.DataOutput
Throws:
java.io.IOException

writeLong

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

Specified by:
writeLong in interface java.io.DataOutput
Throws:
java.io.IOException

writeFloat

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

Specified by:
writeFloat in interface java.io.DataOutput
Throws:
java.io.IOException

writeDouble

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

Specified by:
writeDouble in interface java.io.DataOutput
Throws:
java.io.IOException

writeChars

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

Specified by:
writeChars in interface java.io.DataOutput
Throws:
java.io.IOException

getFD

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

Throws:
java.io.IOException

getFilePointer

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

Throws:
java.io.IOException

length

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

Throws:
java.io.IOException

read

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

Throws:
java.io.IOException

read

public final int read(byte[] b)
               throws java.io.IOException
like RandomAcessFile.read

Throws:
java.io.IOException

read

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

Throws:
java.io.IOException

readFully

public final void readFully(byte[] b)
                     throws java.io.IOException
like RandomAcessFile.readFully

Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException

readFully

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

Specified by:
readFully in interface java.io.DataInput
Throws:
java.io.IOException

skipBytes

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

Specified by:
skipBytes in interface java.io.DataInput
Throws:
java.io.IOException

readBoolean

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

Specified by:
readBoolean in interface java.io.DataInput
Throws:
java.io.IOException

readByte

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

Specified by:
readByte in interface java.io.DataInput
Throws:
java.io.IOException

readUnsignedByte

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

Specified by:
readUnsignedByte in interface java.io.DataInput
Throws:
java.io.IOException

readLine

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

Specified by:
readLine in interface java.io.DataInput
Throws:
java.io.IOException

readUTF

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

Specified by:
readUTF in interface java.io.DataInput
Throws:
java.io.IOException

seek

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

Throws:
java.io.IOException

write

public final void write(int b)
                 throws java.io.IOException
like RandomAcessFile.write

Specified by:
write in interface java.io.DataOutput
Throws:
java.io.IOException

write

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

Specified by:
write in interface java.io.DataOutput
Throws:
java.io.IOException

writeBoolean

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

Specified by:
writeBoolean in interface java.io.DataOutput
Throws:
java.io.IOException

writeByte

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

Specified by:
writeByte in interface java.io.DataOutput
Throws:
java.io.IOException

writeBytes

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

Specified by:
writeBytes in interface java.io.DataOutput
Throws:
java.io.IOException

writeUTF

public final void writeUTF(java.lang.String str)
                    throws java.io.IOException
like RandomAcessFile.writeUTF

Specified by:
writeUTF in interface java.io.DataOutput
Throws:
java.io.IOException

write

public final void write(byte[] b)
                 throws java.io.IOException
like RandomAcessFile.write

Specified by:
write in interface java.io.DataOutput
Throws:
java.io.IOException

close

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

Throws:
java.io.IOException