hep.io.xdr
Class XDRInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--java.io.DataInputStream
|
+--hep.io.xdr.XDRInputStream
- All Implemented Interfaces:
- java.io.DataInput, XDRDataInput
- public class XDRInputStream
- extends java.io.DataInputStream
- implements XDRDataInput
A class for reading XDR files. Not too hard to do in Java since the XDR format is very
similar to the Java native DataStream format, except for String and the fact that elements
(ro an array of elements) are always padded to a multiple of 4 bytes.
This class requires the user to call the pad method, to skip to the next
4-byte boundary after reading an element or array of elements that may not
span a multiple of 4 bytes.
Fields inherited from class java.io.FilterInputStream |
in |
Method Summary |
void |
clearReadLimit()
|
long |
getBytesRead()
|
void |
pad()
Skips appropriate amount to bring stream to 4-byte boundary. |
double[] |
readDoubleArray(double[] buffer)
Reads a double array. |
float[] |
readFloatArray(float[] buffer)
Reads a float array. |
int[] |
readIntArray(int[] buffer)
Reads an integer array. |
java.lang.String |
readString()
Read a String. |
java.lang.String |
readString(int l)
Reads a String of length l bytes, and skips appropriate
amount to bring stream to 4-byte boundary. |
void |
setReadLimit(int bytes)
Sets a limit on the number of bytes that can be read from this file
before an EOF will be generated |
Methods inherited from class java.io.DataInputStream |
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes |
Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.io.DataInput |
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes |
XDRInputStream
public XDRInputStream(java.io.InputStream in)
readString
public java.lang.String readString(int l)
throws java.io.IOException
- Description copied from interface:
XDRDataInput
- Reads a String of length l bytes, and skips appropriate
amount to bring stream to 4-byte boundary.
- Specified by:
readString
in interface XDRDataInput
readString
public java.lang.String readString()
throws java.io.IOException
- Description copied from interface:
XDRDataInput
- Read a String. Assumes int length proceeds String.
Throws an exception if string length > 32767 to protect
against bad data exhausting memory.
- Specified by:
readString
in interface XDRDataInput
readIntArray
public int[] readIntArray(int[] buffer)
throws java.io.IOException
- Description copied from interface:
XDRDataInput
- Reads an integer array. Assumes int length proceeds array.
Throws an exception if array length > 32767 to protect
against bad data exhausting memory. If buffer is not null,
and is large enough to hold array, it is filled and returned,
otherwise a new array is allocated and returned.
- Specified by:
readIntArray
in interface XDRDataInput
readDoubleArray
public double[] readDoubleArray(double[] buffer)
throws java.io.IOException
- Description copied from interface:
XDRDataInput
- Reads a double array. Assumes int length proceeds array.
Throws an exception if array length > 32767 to protect
against bad data exhausting memory. If buffer is not null,
and is large enough to hold array, it is filled and returned,
otherwise a new array is allocated and returned.
- Specified by:
readDoubleArray
in interface XDRDataInput
readFloatArray
public float[] readFloatArray(float[] buffer)
throws java.io.IOException
- Description copied from interface:
XDRDataInput
- Reads a float array. Assumes int length proceeds array.
Throws an exception if array length > 32767 to protect
against bad data exhausting memory. If buffer is not null,
and is large enough to hold array, it is filled and returned,
otherwise a new array is allocated and returned.
- Specified by:
readFloatArray
in interface XDRDataInput
pad
public void pad()
throws java.io.IOException
- Skips appropriate amount to bring stream to 4-byte boundary.
- Specified by:
pad
in interface XDRDataInput
getBytesRead
public long getBytesRead()
setReadLimit
public void setReadLimit(int bytes)
- Sets a limit on the number of bytes that can be read from this file
before an EOF will be generated
clearReadLimit
public void clearReadLimit()