|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.swri.swiftvis.util.BinaryInput
public class BinaryInput
This class is intended to help other parts of the code read in data that is in a FORTRAN, C, or Java binary file. When using this, keep in mind that FORTRAN writes fields with headers and footers that tell you how many bytes are in the field.
Constructor Summary | |
---|---|
BinaryInput(java.io.DataInput di)
|
Method Summary | |
---|---|
void |
close()
Closes the wrapped file. |
byte |
readByte()
Reads a single byte. |
java.lang.String |
readCString()
This reads in C-style string. |
int |
readFortranInt(int numDigits)
This reads a Fortran integer occupying the specified number of characters. |
double[] |
readFortranRecord(java.lang.String format)
This method reads in a record from a Fortran binary file. |
java.lang.String |
readFortranString(int numChars)
This reads a Fortran string occupying the specified number of characters. |
void |
readFully(byte[] b)
Reads a full array of bytes. |
int |
readInt2()
Reads in two bytes and compiles them to an integer value. |
int |
readInt4()
Reads in four bytes and compiles them to an integer value. |
long |
readInt8()
Reads in eight bytes and compiles them to an integer value. |
int |
readIntXDR2()
Reads two bytes and converts them to an int according to XDR format. |
int |
readIntXDR4()
Reads four bytes and converts them to an int according to XDR format. |
long |
readIntXDR8()
Reads eight bytes and converts them to an int according to XDR format. |
int |
readJavaInt2()
Reads two bytes and converts them to an int according to Java format. |
int |
readJavaInt4()
Reads four bytes and converts them to an int according to Java format. |
double |
readJavaReal4()
Reads a float in Java binary format. |
double |
readJavaReal8()
Reads a double in Java binary format. |
double |
readReal4()
This reads in four bytes and tries to convert them to a floating point value. |
double |
readReal8()
This reads in eight bytes and tries to convert them to a floating point value. |
double |
readXDR4()
This reads in a single 4-byte real in XDR format. |
double |
readXDR8()
This reads in a single 8-byte real in XDR format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BinaryInput(java.io.DataInput di)
Method Detail |
---|
public void close() throws java.io.IOException
java.io.IOException
- passes on the exception from the close method.public double readJavaReal4() throws java.io.IOException
java.io.IOException
- This will be thrown if there is a problem reading 4 bytes.public double readJavaReal8() throws java.io.IOException
java.io.IOException
- This will be thrown if there is a problem reading 8 bytes.public double readReal4() throws java.io.IOException
java.io.IOException
- This is thrown if there is a problem reading 4 bytes.public double readReal8() throws java.io.IOException
java.io.IOException
- This is thrown if there is a problem reading 8 bytes.public double readXDR4() throws java.io.IOException
java.io.IOException
- This is thrown if four bytes couldn't be read.public double readXDR8() throws java.io.IOException
java.io.IOException
- This is thrown if eight bytes couldn't be read.public long readInt8() throws java.io.IOException
java.io.IOException
- This is thrown if eight bytes couldn't be read.public int readInt4() throws java.io.IOException
java.io.IOException
- This is thrown if four bytes couldn't be read.public int readInt2() throws java.io.IOException
java.io.IOException
- This is thrown if two bytes couldn't be read.public int readIntXDR2() throws java.io.IOException
java.io.IOException
- This is thrown if two bytes could not be read.public int readIntXDR4() throws java.io.IOException
java.io.IOException
- This is thrown if four bytes could not be read.public long readIntXDR8() throws java.io.IOException
java.io.IOException
- This is thrown if eight bytes could not be read.public int readJavaInt4() throws java.io.IOException
java.io.IOException
- This is thrown if four bytes could not be read.public int readJavaInt2() throws java.io.IOException
java.io.IOException
- This is thrown if two bytes could not be read.public java.lang.String readCString() throws java.io.IOException
java.io.IOException
- This will be thrown if there is an exception before a 0 is read in.public byte readByte() throws java.io.IOException
java.io.IOException
- This is thrown if a byte can't be read.public void readFully(byte[] b) throws java.io.IOException
b
- The byte to read the values into.
java.io.IOException
- This will be thrown if b.length bytes can not be read in.public int readFortranInt(int numDigits) throws java.io.IOException
numDigits
- The number of character to read in.
java.io.IOException
- This is thrown if the specified number of bytes can't be read.public java.lang.String readFortranString(int numChars) throws java.io.IOException
numDigits
- The number of character to read in.
java.io.IOException
- This is thrown if the specified number of bytes can't be read.public double[] readFortranRecord(java.lang.String format) throws java.io.IOException
This method reads in a record from a Fortran binary file. It will read in the header and footer for the record and verify that they are equal and that the number of bytes read in matches them.
The format is specified as a string in a manner similar to that used in general data source. It should be a space separated list of formats. The accepted formats are i, i*2, i*4, i*8, r, r*4, and r*8. The number after the * tells the number of bytes in the integer (i) or floating point (r) value. If no size is specified the i defaults to i*2 and r defaults to r*4. These can be followed by an optional [#] where # is the number of that type you want to read in.
The method returns an array of doubles with one entry for each value read in.
format
- The format string for what to read.
java.io.IOException
- This will be thrown if there is a problem reading in the values.
java.lang.IllegalArgumentException
- This is thrown if the format can't be parsed or if the record sizes don't match.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |