edu.sdsc.grid.io
Class GeneralRandomAccessFile

java.lang.Object
  extended by edu.sdsc.grid.io.GeneralRandomAccessFile
All Implemented Interfaces:
java.io.DataInput, java.io.DataOutput
Direct Known Subclasses:
LocalRandomAccessFile, RemoteRandomAccessFile

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

Instances of this class support I/O on random-access binary files. Methods on the class support conversion between host and file byte orders and word sizes.

Two sets of read methods are provided:

Single-value read methods read a single short, int, long, etc., and return the value.

Multi-value read methods read multiple consecutive shorts, ints, longs, etc., and return them in a given array.

Two sets of write methods are provided:

Single-value write methods write a single short, int, long, etc.

Multi-value write methods write multiple shorts, ints, longs, etc., from an array of values.

Note: This class offers features that extend those found in java.io.RandomAccessFile. However, it is not a subclass, due to the unfortunate use of final methods in java.io.RandomAccessFile.

Since:
JARGON1.0

Field Summary
protected  int fd
          Holds the server information used by this file.
protected  GeneralFile file
          Has this random access file been closed.
protected  BinaryDataFormat fileFormat
          Holds the file's binary data format.
protected  boolean isClosed
          Has this random access file been closed.
protected  java.lang.String mode
           
protected  int rw
          0, if read only 1, if read/write 2, if sync r/w 3, dsync r/w
static int SEEK_CURRENT
          Used to set the offset for seek calls to the current offset of the file.
static int SEEK_END
          Used to set the offset for seek calls to the end of the file.
static int SEEK_START
          Used to set the offset for seek calls to the beginning of the file.
protected  boolean swapNeeded
          Holds a true if the host and file formats have reversed byte orders, forcing bytes to have their order swapped on reads and writes.
 
Constructor Summary
GeneralRandomAccessFile(GeneralFile file, java.lang.String mode)
          Creates a random access file stream to read from, and optionally to write to, the file specified by the GeneralFile argument.
 
Method Summary
abstract  void close()
          Closes this random access file stream and releases any system resources associated with the stream.
protected  void finalize()
          Finalize the object by closing the file.
 BinaryDataFormat getBinaryDataFormat()
          Gets the current binary data format object describing data read from and written to the random access file.
 int getFD()
          Returns the file descriptor associated with this stream.
 GeneralFile getFile()
          Returns the abstract filepath associated with this stream.
abstract  long getFilePointer()
          Returns the current offset in this file.
 GeneralFileSystem getFileSystem()
          Returns the file system object for this file.
 boolean isClosed()
          Returns true if this random access file is closed.
abstract  long length()
          Returns the length of this file.
protected abstract  void open(GeneralFile file)
          Opens a file and returns the file descriptor.
abstract  int read()
          Reads a byte of data from this file.
 int read(byte[] b)
          Reads up to b.length bytes of data from this file into an array of bytes.
 int read(byte[] b, int offset, int len)
          Reads up to len bytes of data from this file into an array of bytes.
 boolean readBoolean()
          Reads a boolean from this file.
 void readBooleans(boolean[] values, int nValues)
          Reads nValues input bytes, each one representing a boolean value, and set each value in a boolean array to true if the corresponding byte is nonzero, false if that byte is zero.
 byte readByte()
          Reads a signed eight-bit value from this file.
protected abstract  int readBytes(byte[] b, int offset, int len)
          Reads a sub array as a sequence of bytes.
 char readChar()
          Reads a Unicode character from this file.
 double readDouble()
          Reads input bytes and returns a double value.
 void readDoubles(double[] values, int nValues)
          Reads input bytes and sets nValues values in an array of doubles.
 float readFloat()
          Reads input bytes and returns a float value.
 void readFloats(float[] values, int nValues)
          Reads input bytes and sets nValues values in an array of floats.
 void readFully(byte[] b)
          Reads b.length bytes from this file into the byte array, starting at the current file pointer.
 void readFully(byte[] b, int offset, int len)
          Reads exactly len bytes from this file into the byte array, starting at the current file pointer.
 int readInt()
          Reads input bytes and returns an int value.
 void readInts(int[] values, int nValues)
          Reads input bytes and sets nValues values in an array of ints.
 java.lang.String readLine()
          Reads the next line of text from this file.
 long readLong()
          Reads input bytes and returns a long value.
 double readLongDouble()
          Reads input bytes and returns a signed value.
 void readLongDoubles(double[] values, int nValues)
          Reads input bytes and sets nValues values in an array of long doubles.
 long readLongLong()
          Reads input bytes and returns a signed value.
 void readLongLongs(long[] values, int nValues)
          Reads input bytes and sets nValues values in an array of long longs.
 void readLongs(long[] values, int nValues)
          Reads input bytes and sets nValues values in an array of longs.
 short readShort()
          Reads input bytes and returns a short value.
 void readShorts(short[] values, int nValues)
          Reads input bytes and sets nValues values in an array of shorts.
 int readUnsignedByte()
          Reads an unsigned eight-bit number from this file.
 long readUnsignedInt()
          Reads input bytes and returns an unsigned value.
 void readUnsignedInts(int[] values, int nValues)
          Reads input bytes and sets nValues values in an array of unsigned ints.
 long readUnsignedLong()
          Reads input bytes and returns an unsigned value.
 long readUnsignedLongLong()
          Reads input bytes and returns an unsigned value.
 void readUnsignedLongLongs(long[] values, int nValues)
          Reads input bytes and sets nValues values in an array of unsigned long longs.
 void readUnsignedLongs(long[] values, int nValues)
          Reads input bytes and sets nValues values in an array of unsigned longs.
 int readUnsignedShort()
          Reads input bytes and returns an unsigned value.
 void readUnsignedShorts(short[] values, int nValues)
          Reads input bytes and sets nValues values in an array of unsigned shorts.
 java.lang.String readUTF()
           
protected  void rwCheck(GeneralFile file, java.lang.String mode)
          Sets the boolean rw value according to the mode and checks that such permissions are available.
 void seek(long position)
          Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
abstract  void seek(long position, int origin)
          Sets the file-pointer offset at which the next read or write occurs.
 void setBinaryDataFormat(BinaryDataFormat bdf)
          Sets the binary data format for data read from and written to the random access file.
abstract  void setLength(long newLength)
          Sets the length of this file.
 int skipBytes(int n)
          Attempts to skip over n bytes of input discarding the skipped bytes.
 java.lang.String toString()
           
 void write(byte[] b)
          Writes b.length bytes from the specified byte array to this file, starting at the current file pointer.
 void write(byte[] b, int offset, int len)
          Writes len bytes from the specified byte array starting at offset off to this file.
 void write(int b)
          Writes the specified byte to this file.
 void write(java.lang.String text)
          Writes a String to the file, by first converting the string to a byte array, using the String.getBytes() method.
 void writeBoolean(boolean v)
          Writes a boolean to the file as a one-byte value.
 void writeBooleans(boolean[] values, int nValues)
          Writes an array of boolean values to this output stream.
 void writeByte(int v)
          Writes a byte to the file as a one-byte value.
protected abstract  void writeBytes(byte[] b, int offset, int len)
          Writes a sub array as a sequence of bytes.
 void writeBytes(java.lang.String s)
          Writes the string to the file as a sequence of bytes.
 void writeChar(int v)
          Writes bytes to the output stream to represent the char value of the argument.
 void writeChars(java.lang.String s)
          Writes a string to the file as a sequence of characters.
 void writeDouble(double v)
          Writes bytes to the output stream to represent the double value of the argument.
 void writeDoubles(double[] values, int nValues)
          Writes bytes to the output stream to represent the double values of the argument array.
 void writeFloat(float v)
          Writes bytes to the output stream to represent the float value of the argument.
 void writeFloats(float[] values, int nValues)
          Writes bytes to the output stream to represent the float values of the argument array.
 void writeInt(int v)
          Writes bytes to the output stream to represent the int value of the argument.
 void writeInts(int[] values, int nValues)
          Writes bytes to the output stream to represent the int values of the argument array.
 void writeLong(long v)
          Writes bytes to the output stream to represent the long value of the argument.
 void writeLongDouble(double v)
          Writes bytes to the output stream to represent the long double value of the argument.
 void writeLongDoubles(double[] values, int nValues)
          Writes bytes to the output stream to represent the long double values of the argument array.
 void writeLongLong(long v)
          Writes bytes to the output stream to represent the long long value of the argument.
 void writeLongLongs(long[] values, int nValues)
          Writes bytes to the output stream to represent the long long values of the argument array.
 void writeLongs(long[] values, int nValues)
          Writes bytes to the output stream to represent the long values of the argument array.
 void writeShort(int v)
          Writes bytes to the output stream to represent the short value of the argument.
 void writeShorts(short[] values, int nValues)
          Writes bytes to the output stream to represent the short values of the argument array.
 void writeUTF(java.lang.String str)
          Writes a string to the file using UTF-8 encoding in a machine-independent manner.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEEK_START

public static final int SEEK_START
Used to set the offset for seek calls to the beginning of the file. Same as SEEK_SET (as in C/C++, but that name is less intuitive)

See Also:
Constant Field Values

SEEK_CURRENT

public static final int SEEK_CURRENT
Used to set the offset for seek calls to the current offset of the file. Same as SEEK_CUR (as in C/C++, but that name is less intuitive)

See Also:
Constant Field Values

SEEK_END

public static final int SEEK_END
Used to set the offset for seek calls to the end of the file.

See Also:
Constant Field Values

fd

protected int fd
Holds the server information used by this file.


rw

protected int rw
0, if read only 1, if read/write 2, if sync r/w 3, dsync r/w


fileFormat

protected BinaryDataFormat fileFormat
Holds the file's binary data format.


swapNeeded

protected boolean swapNeeded
Holds a true if the host and file formats have reversed byte orders, forcing bytes to have their order swapped on reads and writes.


isClosed

protected boolean isClosed
Has this random access file been closed. A closed random access file cannot perform input or output operations and cannot be reopened.


file

protected GeneralFile file
Has this random access file been closed. A closed random access file cannot perform input or output operations and cannot be reopened.


mode

protected java.lang.String mode
Constructor Detail

GeneralRandomAccessFile

public GeneralRandomAccessFile(GeneralFile file,
                               java.lang.String mode)
                        throws java.io.IOException,
                               java.lang.SecurityException
Creates a random access file stream to read from, and optionally to write to, the file specified by the GeneralFile argument. A new file descriptor is obtained which represents the connection to the file.

The mode argument specifies the access mode in which the file is to be opened. The permitted values and their meanings are:

"r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOException to be thrown.
"rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it.
"rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
"rwd"   Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.
On construction a check is made to see if read access to the file is allowed. If the mode allows writing, write access to the file is also checked.

Parameters:
file - the file object
mode - the access mode, as described above
Throws:
java.io.IOException - If an I/O error occurs
java.lang.IllegalArgumentException - if the mode argument is not equal to one of "r", "rw", "rws", or "rwd"
java.io.FileNotFoundException - If the file exists but is a directory rather than a regular file, or cannot be opened or created for any other reason
java.lang.SecurityException - If denied read access to the file or the mode is "rw" and denied write access to the file.
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalize the object by closing the file.

Overrides:
finalize in class java.lang.Object
Throws:
throws - Throwable If the file cannot be closed.
java.lang.Throwable

rwCheck

protected void rwCheck(GeneralFile file,
                       java.lang.String mode)
                throws java.lang.IllegalArgumentException,
                       java.lang.SecurityException
Sets the boolean rw value according to the mode and checks that such permissions are available.

"r" would allow for read-only access. "rw" would allow for read-write access. Case-insensitive.

Throws:
java.lang.IllegalArgumentException - the mode is invalid.
java.lang.SecurityException - if the permissions are wrong.

getFD

public int getFD()
Returns the file descriptor associated with this stream.

Returns:
the file descriptor object associated with this stream.
Throws:
java.lang.IllegalArgumentException - if an error occurs.
See Also:
FileDescriptor

getFile

public GeneralFile getFile()
Returns the abstract filepath associated with this stream.

Returns:
the abstract filepath object associated with this stream.

getFileSystem

public GeneralFileSystem getFileSystem()
Returns the file system object for this file.

Returns:
GeneralFileSystem
Throws:
java.lang.NullPointerException - if fileSystem is null.

open

protected abstract void open(GeneralFile file)
                      throws java.io.IOException
Opens a file and returns the file descriptor. The file is opened in read-write mode if writeable is true, else the file is opened as read-only. If the name refers to a directory, an IOException is thrown.

Parameters:
name - the name of the file
mode - the mode flags, a combination of the O_ constants defined above
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

read

public abstract int read()
                  throws java.io.IOException
Reads a byte of data from this file. The byte is returned as an integer in the range 0 to 255 (0x00-0x0ff). This method blocks if no input is yet available.

Although GeneralRandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as java.io.InputStream.read().

Returns:
the next byte of data, or -1 if the end of the file has been reached.
Throws:
java.io.IOException - if an I/O error occurs. Not thrown if end-of-file has been reached.

readBytes

protected abstract int readBytes(byte[] b,
                                 int offset,
                                 int len)
                          throws java.io.IOException
Reads a sub array as a sequence of bytes.

Parameters:
b - the data to be written
off - the start offset in the data
len - the number of bytes that are written
Throws:
java.io.IOException - If an I/O error has occurred.

read

public int read(byte[] b,
                int offset,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although GeneralRandomAccessFile is not a subclass of InputStream, this method behaves in the exactly the same way as java.io.InputStream.read(byte[], int, int).

Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached.
Throws:
java.io.IOException - if an I/O error occurs.

read

public int read(byte[] b)
         throws java.io.IOException
Reads up to b.length bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although GeneralRandomAccessFile is not a subclass of InputStream, this method behaves in the exactly the same way as java.io.InputStream.read(byte[]).

Parameters:
b - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of this file has been reached.
Throws:
java.io.IOException - if an I/O error occurs.

readFully

public void readFully(byte[] b)
               throws java.io.IOException
Reads b.length bytes from this file into the byte array, starting at the current file pointer. This method reads repeatedly from the file until the requested number of bytes are read. This method blocks until the requested number of bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readFully in interface java.io.DataInput
Parameters:
b - the buffer into which the data is read.
Throws:
java.io.EOFException - if this file reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

readFully

public void readFully(byte[] b,
                      int offset,
                      int len)
               throws java.io.IOException
Reads exactly len bytes from this file into the byte array, starting at the current file pointer. This method reads repeatedly from the file until the requested number of bytes are read. This method blocks until the requested number of bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readFully in interface java.io.DataInput
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the number of bytes to read.
Throws:
java.io.EOFException - if this file reaches the end before reading all the bytes.
java.io.IOException - if an I/O error occurs.

skipBytes

public int skipBytes(int n)
              throws java.io.IOException
Attempts to skip over n bytes of input discarding the skipped bytes.

This method may skip over some smaller number of bytes, possibly zero. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. This method never throws an EOFException. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

Specified by:
skipBytes in interface java.io.DataInput
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this file. The write starts at the current file pointer.

Specified by:
write in interface java.io.DataOutput
Parameters:
b - the byte to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeBytes

protected abstract void writeBytes(byte[] b,
                                   int offset,
                                   int len)
                            throws java.io.IOException
Writes a sub array as a sequence of bytes.

Parameters:
b - the data to be written
off - the start offset in the data
len - the number of bytes that are written
Throws:
java.io.IOException - If an I/O error has occurred.

write

public void write(byte[] b)
           throws java.io.IOException
Writes b.length bytes from the specified byte array to this file, starting at the current file pointer.

Specified by:
write in interface java.io.DataOutput
Parameters:
b - the data.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(byte[] b,
                  int offset,
                  int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to this file.

Specified by:
write in interface java.io.DataOutput
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(java.lang.String text)
           throws java.io.IOException
Writes a String to the file, by first converting the string to a byte array, using the String.getBytes() method.

Parameters:
text - the data.
Throws:
java.io.IOException - if an I/O error occurs.

getFilePointer

public abstract long getFilePointer()
                             throws java.io.IOException
Returns the current offset in this file.

Returns:
the offset from the beginning of the file, in bytes, at which the next read or write occurs.
Throws:
java.io.IOException - if an I/O error occurs.

seek

public void seek(long position)
          throws java.io.IOException
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.

Parameters:
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
Throws:
java.io.IOException - if pos is less than 0 or if an I/O error occurs.

seek

public abstract void seek(long position,
                          int origin)
                   throws java.io.IOException
Sets the file-pointer offset at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.

Parameters:
pos - the offset position, measured in bytes from the at which to set the file pointer.
origin - a Sets offset for the beginning of the seek.
SEEK_START - sets the offset from the beginning of the file. SEEK_CURRENT - sets the offset from the current position of the filePointer.
SEEK_END - sets the offset from the end of the file.
Throws:
java.io.IOException - if pos is less than 0 or if an I/O error occurs.

length

public abstract long length()
                     throws java.io.IOException
Returns the length of this file.

Returns:
the length of this file, measured in bytes.
Throws:
java.io.IOException - if an I/O error occurs.

setLength

public abstract void setLength(long newLength)
                        throws java.io.IOException
Sets the length of this file.

If the present length of the file as returned by the length method is greater than the newLength argument then the file will be truncated. In this case, if the file offset as returned by the getFilePointer method is greater then newLength then after this method returns the offset will be equal to newLength.

If the present length of the file as returned by the length method is smaller than the newLength argument then the file will be extended. In this case, the contents of the extended portion of the file are not defined.

Parameters:
newLength - The desired length of the file
Throws:
java.io.IOException - If an I/O error occurs

close

public abstract void close()
                    throws java.io.IOException
Closes this random access file stream and releases any system resources associated with the stream. A closed random access file cannot perform input or output operations and cannot be reopened.

Throws:
java.io.IOException - if an I/O error occurs.

isClosed

public boolean isClosed()
Returns true if this random access file is closed. A closed random access file cannot perform input or output operations and cannot be reopened.

Throws:
java.io.IOException - if an I/O error occurs.

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Reads a boolean from this file. This method reads a single byte from the file, starting at the current file pointer. A value of 0 represents false. Any other value represents true. This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readBoolean in interface java.io.DataInput
Returns:
the boolean value read.
Throws:
java.io.EOFException - if this file has reached the end.
java.io.IOException - if an I/O error occurs.

readByte

public byte readByte()
              throws java.io.IOException
Reads a signed eight-bit value from this file. This method reads a byte from the file, starting from the current file pointer. If the byte read is b, where 0 <= b <= 255, then the result is:
     (byte)(b)
 

This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readByte in interface java.io.DataInput
Returns:
the next byte of this file as a signed eight-bit byte.
Throws:
java.io.EOFException - if this file has reached the end.
java.io.IOException - if an I/O error occurs.

readUnsignedByte

public int readUnsignedByte()
                     throws java.io.IOException
Reads an unsigned eight-bit number from this file. This method reads a byte from this file, starting at the current file pointer, and returns that byte.

This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readUnsignedByte in interface java.io.DataInput
Returns:
the next byte of this file, interpreted as an unsigned eight-bit number.
Throws:
java.io.EOFException - if this file has reached the end.
java.io.IOException - if an I/O error occurs.

readShort

public short readShort()
                throws java.io.EOFException,
                       java.io.IOException
Reads input bytes and returns a short value. The number of bytes read is equal to the size of a short using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeShort method of interface BinaryDataOutput.

Specified by:
readShort in interface java.io.DataInput
Returns:
the value read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedShort

public int readUnsignedShort()
                      throws java.io.IOException,
                             java.io.EOFException
Reads input bytes and returns an unsigned value. The number of bytes read is equal to the size of an unsigned short using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeInt method of interface BinaryDataOutput.

Specified by:
readUnsignedShort in interface java.io.DataInput
Returns:
the unsigned value
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readChar

public char readChar()
              throws java.io.IOException
Reads a Unicode character from this file. This method reads two bytes from the file, starting at the current file pointer. If the bytes read, in order, are b1 and b2, where 0 <= b1, b2 <= 255, then the result is equal to:
     (char)((b1 << 8) | b2)
 

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readChar in interface java.io.DataInput
Returns:
the next two bytes of this file as a Unicode character.
Throws:
java.io.EOFException - if this file reaches the end before reading two bytes.
java.io.IOException - if an I/O error occurs.

readInt

public int readInt()
            throws java.io.EOFException,
                   java.io.IOException
Reads input bytes and returns an int value. The number of bytes read is equal to the size of an int using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeInt method of interface BinaryDataOutput.

Specified by:
readInt in interface java.io.DataInput
Returns:
the value read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedInt

public long readUnsignedInt()
                     throws java.io.IOException,
                            java.io.EOFException
Reads input bytes and returns an unsigned value. The number of bytes read is equal to the size of an unsigned int using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeInt method of interface BinaryDataOutput.

Returns:
the unsigned value
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readLong

public long readLong()
              throws java.io.EOFException,
                     java.io.IOException
Reads input bytes and returns a long value. The number of bytes read is equal to the size of a long using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeLong method of interface BinaryDataOutput.

Specified by:
readLong in interface java.io.DataInput
Returns:
the value read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedLong

public long readUnsignedLong()
                      throws java.io.IOException,
                             java.io.EOFException
Reads input bytes and returns an unsigned value. The number of bytes read is equal to the size of an unsigned long using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeLong method of interface BinaryDataOutput.

Returns:
the unsigned value
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedLongLong

public long readUnsignedLongLong()
                          throws java.io.IOException,
                                 java.io.EOFException
Reads input bytes and returns an unsigned value. The number of bytes read is equal to the size of an unsigned long long using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeLongLong method of interface BinaryDataOutput.

Returns:
the unsigned value
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readLongLong

public long readLongLong()
                  throws java.io.IOException,
                         java.io.EOFException
Reads input bytes and returns a signed value. The number of bytes read is equal to the size of a long long using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeLongLong method of interface BinaryDataOutput.

Returns:
the value
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readLongDouble

public double readLongDouble()
                      throws java.io.IOException,
                             java.io.EOFException
Reads input bytes and returns a signed value. The number of bytes read is equal to the size of a long double using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeLongDouble method of interface BinaryDataOutput.

Returns:
the value
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readFloat

public float readFloat()
                throws java.io.EOFException,
                       java.io.IOException
Reads input bytes and returns a float value. The number of bytes read is equal to the size of a float using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeFloat method of interface BinaryDataOutput.

Specified by:
readFloat in interface java.io.DataInput
Returns:
the value read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readDouble

public double readDouble()
                  throws java.io.EOFException,
                         java.io.IOException
Reads input bytes and returns a double value. The number of bytes read is equal to the size of a double using the current binary data format.

The data read by this method is converted from the file's binary data format to that of host running this application. This may involve a change in byte order and data type size.

This method is suitable for reading the bytes written by the writeDouble method of interface BinaryDataOutput.

Specified by:
readDouble in interface java.io.DataInput
Returns:
the value read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads the next line of text from this file. This method successively reads bytes from the file, starting at the current file pointer, until it reaches a line terminator or the end of the file. Each byte is converted into a character by taking the byte's value for the lower eight bits of the character and setting the high eight bits of the character to zero. This method does not, therefore, support the full Unicode character set.

A line of text is terminated by a carriage-return character ('\r'), a newline character ('\n'), a carriage-return character immediately followed by a newline character, or the end of the file. Line-terminating characters are discarded and are not included as part of the string returned.

This method blocks until a newline character is read, a carriage return and the byte following it are read (to see if it is a newline), the end of the file is reached, or an exception is thrown.

Specified by:
readLine in interface java.io.DataInput
Returns:
the next line of text from this file, or null if end of file is encountered before even one byte is read.
Throws:
java.io.IOException - if an I/O error occurs.

readUTF

public java.lang.String readUTF()
                         throws java.io.IOException
Specified by:
readUTF in interface java.io.DataInput
Throws:
java.lang.UnsupportedOperationException - not yet supported.
java.io.IOException

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException
Writes a boolean to the file as a one-byte value. The value true is written out as the value (byte)1; the value false is written out as the value (byte)0. The write starts at the current position of the file pointer.

Specified by:
writeBoolean in interface java.io.DataOutput
Parameters:
v - a boolean value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeByte

public void writeByte(int v)
               throws java.io.IOException
Writes a byte to the file as a one-byte value. The write starts at the current position of the file pointer.

Specified by:
writeByte in interface java.io.DataOutput
Parameters:
v - a byte value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeShort

public void writeShort(int v)
                throws java.io.IOException
Writes bytes to the output stream to represent the short value of the argument. The number of bytes written is equal to the size of a short using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readShort method of interface BinaryDataInput, which will then return a short equal to (short)v.

Specified by:
writeShort in interface java.io.DataOutput
Parameters:
v - the short value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeChar

public void writeChar(int v)
               throws java.io.IOException
Writes bytes to the output stream to represent the char value of the argument. The number of bytes written is equal to the size of a char using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readChar method of interface BinaryDataInput, which will then return a char equal to (char)v.

Specified by:
writeChar in interface java.io.DataOutput
Parameters:
v - the short value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeInt

public void writeInt(int v)
              throws java.io.IOException
Writes bytes to the output stream to represent the int value of the argument. The number of bytes written is equal to the size of an int using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readInt method of interface BinaryDataInput, which will then return a int equal to (int)v.

Specified by:
writeInt in interface java.io.DataOutput
Parameters:
v - the int value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeLong

public void writeLong(long v)
               throws java.io.IOException
Writes bytes to the output stream to represent the long value of the argument. The number of bytes written is equal to the size of a long using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readLong method of interface BinaryDataInput, which will then return a long equal to (long)v.

Specified by:
writeLong in interface java.io.DataOutput
Parameters:
v - the long value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeLongLong

public void writeLongLong(long v)
                   throws java.io.IOException
Writes bytes to the output stream to represent the long long value of the argument. The number of bytes written is equal to the size of a long long using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readLongLong method of interface BinaryDataInput, which will then return a long long equal to (long long)v.

Parameters:
v - the long long value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeLongDouble

public void writeLongDouble(double v)
                     throws java.io.IOException
Writes bytes to the output stream to represent the long double value of the argument. The number of bytes written is equal to the size of a long double using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readLongDouble method of interface BinaryDataInput, which will then return a long double equal to (long double)v.

Parameters:
v - the long double value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeFloat

public void writeFloat(float v)
                throws java.io.IOException
Writes bytes to the output stream to represent the float value of the argument. The number of bytes written is equal to the size of a float using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readFloat method of interface BinaryDataInput, which will then return a float equal to (float)v.

Specified by:
writeFloat in interface java.io.DataOutput
Parameters:
v - the float value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeDouble

public void writeDouble(double v)
                 throws java.io.IOException
Writes bytes to the output stream to represent the double value of the argument. The number of bytes written is equal to the size of a double using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readFloat method of interface BinaryDataInput, which will then return a double equal to (double)v.

Specified by:
writeDouble in interface java.io.DataOutput
Parameters:
v - the double value to be written
Throws:
java.io.IOException - if an I/O error occurs

writeBytes

public void writeBytes(java.lang.String s)
                throws java.io.IOException
Writes the string to the file as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits. The write starts at the current position of the file pointer.

Specified by:
writeBytes in interface java.io.DataOutput
Parameters:
s - a string of bytes to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeChars

public void writeChars(java.lang.String s)
                throws java.io.IOException
Writes a string to the file as a sequence of characters. Each character is written to the data output stream as if by the writeChar method. The write starts at the current position of the file pointer.

Specified by:
writeChars in interface java.io.DataOutput
Parameters:
s - a String value to be written.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
writeChar(int)

writeUTF

public void writeUTF(java.lang.String str)
              throws java.io.IOException
Writes a string to the file using UTF-8 encoding in a machine-independent manner.

First, two bytes are written to the file, starting at the current file pointer, as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the UTF-8 encoding for each character.

Specified by:
writeUTF in interface java.io.DataOutput
Parameters:
str - a string to be written.
Throws:
java.io.IOException - if an I/O error occurs.

setBinaryDataFormat

public void setBinaryDataFormat(BinaryDataFormat bdf)
Sets the binary data format for data read from and written to the random access file. If the given format object is a null, no change is made to the current data format.

Parameters:
bdf - the new file BinaryDataFormat object

getBinaryDataFormat

public BinaryDataFormat getBinaryDataFormat()
Gets the current binary data format object describing data read from and written to the random access file.

Returns:
the current BinaryDataFormat object

readBooleans

public void readBooleans(boolean[] values,
                         int nValues)
                  throws java.io.EOFException,
                         java.io.IOException
Reads nValues input bytes, each one representing a boolean value, and set each value in a boolean array to true if the corresponding byte is nonzero, false if that byte is zero. This method is suitable for reading the byte written by the writeBooleans method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readDoubles

public void readDoubles(double[] values,
                        int nValues)
                 throws java.io.EOFException,
                        java.io.IOException
Reads input bytes and sets nValues values in an array of doubles. The number of bytes read for each double is equal to the size of a double in the current binary data format.

The data read by this method is assumed to be in the host's byte order, data type size, and floating-point format. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeDoubles method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readFloats

public void readFloats(float[] values,
                       int nValues)
                throws java.io.EOFException,
                       java.io.IOException
Reads input bytes and sets nValues values in an array of floats. The number of bytes read for each float is equal to the size of a float in the current binary data format.

The data read by this method is assumed to be in the host's byte order, data type size, and floating-point format. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeFloats method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readInts

public void readInts(int[] values,
                     int nValues)
              throws java.io.EOFException,
                     java.io.IOException
Reads input bytes and sets nValues values in an array of ints. The number of bytes read for each int is equal to the size of a int in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeInts method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readLongs

public void readLongs(long[] values,
                      int nValues)
               throws java.io.EOFException,
                      java.io.IOException
Reads input bytes and sets nValues values in an array of longs. The number of bytes read for each long is equal to the size of a long in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeLongs method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readLongDoubles

public void readLongDoubles(double[] values,
                            int nValues)
                     throws java.io.EOFException,
                            java.io.IOException
Reads input bytes and sets nValues values in an array of long doubles. The number of bytes read for each long double is equal to the size of a long double in the current binary data format.

The data read by this method is assumed to be in the host's byte order, data type size, and floating-point format. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeDoubles method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readLongLongs

public void readLongLongs(long[] values,
                          int nValues)
                   throws java.io.EOFException,
                          java.io.IOException
Reads input bytes and sets nValues values in an array of long longs. The number of bytes read for each long long is equal to the size of a long long in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeLongs method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readShorts

public void readShorts(short[] values,
                       int nValues)
                throws java.io.EOFException,
                       java.io.IOException
Reads input bytes and sets nValues values in an array of shorts. The number of bytes read for each short is equal to the size of a short in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeShorts method of interface BinaryDataOutput.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedShorts

public void readUnsignedShorts(short[] values,
                               int nValues)
                        throws java.io.EOFException,
                               java.io.IOException
Reads input bytes and sets nValues values in an array of unsigned shorts. The number of bytes read for each unsigned short is equal to the size of a unsigned short in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeShorts method of interface BinaryDataOutput if the argument to writeShort was intended to be an unsigned value.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedInts

public void readUnsignedInts(int[] values,
                             int nValues)
                      throws java.io.EOFException,
                             java.io.IOException
Reads input bytes and sets nValues values in an array of unsigned ints. The number of bytes read for each unsigned int is equal to the size of a unsigned int in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeShorts method of interface BinaryDataOutput if the argument to writeShort was intended to be an unsigned value.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedLongs

public void readUnsignedLongs(long[] values,
                              int nValues)
                       throws java.io.EOFException,
                              java.io.IOException
Reads input bytes and sets nValues values in an array of unsigned longs. The number of bytes read for each unsigned long is equal to the size of a unsigned long in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeShorts method of interface BinaryDataOutput if the argument to writeShort was intended to be an unsigned value.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

readUnsignedLongLongs

public void readUnsignedLongLongs(long[] values,
                                  int nValues)
                           throws java.io.EOFException,
                                  java.io.IOException
Reads input bytes and sets nValues values in an array of unsigned long longs. The number of bytes read for each unsigned long long is equal to the size of a unsigned long long in the current binary data format.

The data read by this method is assumed to be in the host's byte order and data type size. If the host uses Most-significant-Byte-First (MBF) byte ordering, then the first byte read will contain the highest-order bits of the value, and so on. Otherwise if the host uses Least-significant-Byte-First (LBF) byte ordering, then the first byte read will contain the lowest-order bits of the value, and so on.

This method is suitable for reading the bytes written by the writeShorts method of interface BinaryDataOutput if the argument to writeShort was intended to be an unsigned value.

Parameters:
values - the array of values to set
nValues - the number of values to read
Throws:
java.io.EOFException - if this stream reaches the end before reading all the bytes
java.io.IOException - if an I/O error occurs

writeBooleans

public void writeBooleans(boolean[] values,
                          int nValues)
                   throws java.io.IOException
Writes an array of boolean values to this output stream. For each true value, a (byte)1 is written; otherwise for a false value, a (byte)0 is written. The bytes written by this method may be read by the readBooleans method of interface BinaryDataInput, which will then return booleans equal to those in the values array.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs

writeDoubles

public void writeDoubles(double[] values,
                         int nValues)
                  throws java.io.IOException
Writes bytes to the output stream to represent the double values of the argument array. The number of bytes written for each value is equal to the size of a double using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readFloats method of interface BinaryDataInput.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs

writeFloats

public void writeFloats(float[] values,
                        int nValues)
                 throws java.io.IOException
Writes bytes to the output stream to represent the float values of the argument array. The number of bytes written for each value is equal to the size of a float using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readFloats method of interface BinaryDataInput.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs

writeInts

public void writeInts(int[] values,
                      int nValues)
               throws java.io.IOException
Writes bytes to the output stream to represent the int values of the argument array. The number of bytes written for each value is equal to the size of a int using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readInts method of interface BinaryDataInput.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs

writeLongs

public void writeLongs(long[] values,
                       int nValues)
                throws java.io.IOException
Writes bytes to the output stream to represent the long values of the argument array. The number of bytes written for each value is equal to the size of a long using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readLongs method of interface BinaryDataInput.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs

writeShorts

public void writeShorts(short[] values,
                        int nValues)
                 throws java.io.IOException
Writes bytes to the output stream to represent the short values of the argument array. The number of bytes written for each value is equal to the size of a short using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readShorts method of interface BinaryDataInput.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs

writeLongLongs

public void writeLongLongs(long[] values,
                           int nValues)
                    throws java.io.IOException
Writes bytes to the output stream to represent the long long values of the argument array. The number of bytes written for each value is equal to the size of a long long using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readShorts method of interface BinaryDataInput.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs

writeLongDoubles

public void writeLongDoubles(double[] values,
                             int nValues)
                      throws java.io.IOException
Writes bytes to the output stream to represent the long double values of the argument array. The number of bytes written for each value is equal to the size of a long double using the current binary data format.

The data written by this method is converted from the host's binary data format to that for the file. This may involve a change in byte order and data type size.

The bytes written by this method may be read by the readShorts method of interface BinaryDataInput.

Parameters:
values - the array of values to be written
nValues - the number of values to write
Throws:
java.io.IOException - if an I/O error occurs