|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.sdsc.grid.io.GeneralRandomAccessFile
public abstract class GeneralRandomAccessFile
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.
| 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() |
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 |
|---|
public static final int SEEK_START
public static final int SEEK_CURRENT
public static final int SEEK_END
protected int fd
protected int rw
protected BinaryDataFormat fileFormat
protected boolean swapNeeded
protected boolean isClosed
protected GeneralFile file
protected java.lang.String mode
| Constructor Detail |
|---|
public GeneralRandomAccessFile(GeneralFile file,
java.lang.String mode)
throws java.io.IOException,
java.lang.SecurityException
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:
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.
"r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOExceptionto 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.
file - the file objectmode - the access mode, as described
above
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 |
|---|
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectthrows - Throwable If the file cannot be closed.
java.lang.Throwable
protected void rwCheck(GeneralFile file,
java.lang.String mode)
throws java.lang.IllegalArgumentException,
java.lang.SecurityException
"r" would allow for read-only access. "rw" would allow for read-write access. Case-insensitive.
java.lang.IllegalArgumentException - the mode is invalid.
java.lang.SecurityException - if the permissions are wrong.public int getFD()
java.lang.IllegalArgumentException - if an error occurs.FileDescriptorpublic GeneralFile getFile()
public GeneralFileSystem getFileSystem()
java.lang.NullPointerException - if fileSystem is null.
protected abstract void open(GeneralFile file)
throws java.io.IOException
name refers to a directory, an IOException
is thrown.
name - the name of the filemode - the mode flags, a combination of the O_ constants
defined above
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object
public abstract int read()
throws java.io.IOException
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().
-1 if the end of the
file has been reached.
java.io.IOException - if an I/O error occurs. Not thrown if
end-of-file has been reached.
protected abstract int readBytes(byte[] b,
int offset,
int len)
throws java.io.IOException
b - the data to be writtenoff - the start offset in the datalen - the number of bytes that are written
java.io.IOException - If an I/O error has occurred.
public int read(byte[] b,
int offset,
int len)
throws java.io.IOException
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).
b - the buffer into which the data is read.off - the start offset of the data.len - the maximum number of bytes read.
-1 if there is no more data because the end of
the file has been reached.
java.io.IOException - if an I/O error occurs.
public int read(byte[] b)
throws java.io.IOException
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[]).
b - the buffer into which the data is read.
-1 if there is no more data because the end of
this file has been reached.
java.io.IOException - if an I/O error occurs.
public void readFully(byte[] b)
throws java.io.IOException
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.
readFully in interface java.io.DataInputb - the buffer into which the data is read.
java.io.EOFException - if this file reaches the end before reading
all the bytes.
java.io.IOException - if an I/O error occurs.
public void readFully(byte[] b,
int offset,
int len)
throws java.io.IOException
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.
readFully in interface java.io.DataInputb - the buffer into which the data is read.off - the start offset of the data.len - the number of bytes to read.
java.io.EOFException - if this file reaches the end before reading
all the bytes.
java.io.IOException - if an I/O error occurs.
public int skipBytes(int n)
throws java.io.IOException
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.
skipBytes in interface java.io.DataInputn - the number of bytes to be skipped.
java.io.IOException - if an I/O error occurs.
public void write(int b)
throws java.io.IOException
write in interface java.io.DataOutputb - the byte to be written.
java.io.IOException - if an I/O error occurs.
protected abstract void writeBytes(byte[] b,
int offset,
int len)
throws java.io.IOException
b - the data to be writtenoff - the start offset in the datalen - the number of bytes that are written
java.io.IOException - If an I/O error has occurred.
public void write(byte[] b)
throws java.io.IOException
b.length bytes from the specified byte array
to this file, starting at the current file pointer.
write in interface java.io.DataOutputb - the data.
java.io.IOException - if an I/O error occurs.
public void write(byte[] b,
int offset,
int len)
throws java.io.IOException
len bytes from the specified byte array
starting at offset off to this file.
write in interface java.io.DataOutputb - the data.off - the start offset in the data.len - the number of bytes to write.
java.io.IOException - if an I/O error occurs.
public void write(java.lang.String text)
throws java.io.IOException
String.getBytes() method.
- Parameters:
text - the data.
- Throws:
java.io.IOException - if an I/O error occurs.
public abstract long getFilePointer()
throws java.io.IOException
java.io.IOException - if an I/O error occurs.
public void seek(long position)
throws java.io.IOException
pos - the offset position, measured in bytes from the
beginning of the file, at which to set the file
pointer.
java.io.IOException - if pos is less than
0 or if an I/O error occurs.
public abstract void seek(long position,
int origin)
throws java.io.IOException
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.java.io.IOException - if pos is less than
0 or if an I/O error occurs.
public abstract long length()
throws java.io.IOException
java.io.IOException - if an I/O error occurs.
public abstract void setLength(long newLength)
throws java.io.IOException
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.
newLength - The desired length of the file
java.io.IOException - If an I/O error occurs
public abstract void close()
throws java.io.IOException
java.io.IOException - if an I/O error occurs.public boolean isClosed()
java.io.IOException - if an I/O error occurs.
public boolean readBoolean()
throws java.io.IOException
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.
readBoolean in interface java.io.DataInputboolean value read.
java.io.EOFException - if this file has reached the end.
java.io.IOException - if an I/O error occurs.
public byte readByte()
throws java.io.IOException
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.
readByte in interface java.io.DataInputbyte.
java.io.EOFException - if this file has reached the end.
java.io.IOException - if an I/O error occurs.
public int readUnsignedByte()
throws java.io.IOException
This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.
readUnsignedByte in interface java.io.DataInputjava.io.EOFException - if this file has reached the end.
java.io.IOException - if an I/O error occurs.
public short readShort()
throws java.io.EOFException,
java.io.IOException
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.
readShort in interface java.io.DataInputjava.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public int readUnsignedShort()
throws java.io.IOException,
java.io.EOFException
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.
readUnsignedShort in interface java.io.DataInputjava.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public char readChar()
throws java.io.IOException
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.
readChar in interface java.io.DataInputjava.io.EOFException - if this file reaches the end before reading
two bytes.
java.io.IOException - if an I/O error occurs.
public int readInt()
throws java.io.EOFException,
java.io.IOException
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.
readInt in interface java.io.DataInputjava.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public long readUnsignedInt()
throws java.io.IOException,
java.io.EOFException
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.
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public long readLong()
throws java.io.EOFException,
java.io.IOException
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.
readLong in interface java.io.DataInputjava.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public long readUnsignedLong()
throws java.io.IOException,
java.io.EOFException
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.
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public long readUnsignedLongLong()
throws java.io.IOException,
java.io.EOFException
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.
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public long readLongLong()
throws java.io.IOException,
java.io.EOFException
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.
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public double readLongDouble()
throws java.io.IOException,
java.io.EOFException
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.
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public float readFloat()
throws java.io.EOFException,
java.io.IOException
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.
readFloat in interface java.io.DataInputjava.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public double readDouble()
throws java.io.EOFException,
java.io.IOException
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.
readDouble in interface java.io.DataInputjava.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public java.lang.String readLine()
throws java.io.IOException
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.
readLine in interface java.io.DataInputjava.io.IOException - if an I/O error occurs.
public java.lang.String readUTF()
throws java.io.IOException
readUTF in interface java.io.DataInputjava.lang.UnsupportedOperationException - not yet supported.
java.io.IOException
public void writeBoolean(boolean v)
throws java.io.IOException
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.
writeBoolean in interface java.io.DataOutputv - a boolean value to be written.
java.io.IOException - if an I/O error occurs.
public void writeByte(int v)
throws java.io.IOException
byte to the file as a one-byte value. The
write starts at the current position of the file pointer.
writeByte in interface java.io.DataOutputv - a byte value to be written.
java.io.IOException - if an I/O error occurs.
public void writeShort(int v)
throws java.io.IOException
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.
writeShort in interface java.io.DataOutputv - the short value to be written
java.io.IOException - if an I/O error occurs
public void writeChar(int v)
throws java.io.IOException
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.
writeChar in interface java.io.DataOutputv - the short value to be written
java.io.IOException - if an I/O error occurs
public void writeInt(int v)
throws java.io.IOException
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.
writeInt in interface java.io.DataOutputv - the int value to be written
java.io.IOException - if an I/O error occurs
public void writeLong(long v)
throws java.io.IOException
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.
writeLong in interface java.io.DataOutputv - the long value to be written
java.io.IOException - if an I/O error occurs
public void writeLongLong(long v)
throws java.io.IOException
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.
v - the long long value to be written
java.io.IOException - if an I/O error occurs
public void writeLongDouble(double v)
throws java.io.IOException
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.
v - the long double value to be written
java.io.IOException - if an I/O error occurs
public void writeFloat(float v)
throws java.io.IOException
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.
writeFloat in interface java.io.DataOutputv - the float value to be written
java.io.IOException - if an I/O error occurs
public void writeDouble(double v)
throws java.io.IOException
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.
writeDouble in interface java.io.DataOutputv - the double value to be written
java.io.IOException - if an I/O error occurs
public void writeBytes(java.lang.String s)
throws java.io.IOException
writeBytes in interface java.io.DataOutputs - a string of bytes to be written.
java.io.IOException - if an I/O error occurs.
public void writeChars(java.lang.String s)
throws java.io.IOException
writeChar method. The write starts at the current
position of the file pointer.
writeChars in interface java.io.DataOutputs - a String value to be written.
java.io.IOException - if an I/O error occurs.writeChar(int)
public void writeUTF(java.lang.String str)
throws java.io.IOException
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.
writeUTF in interface java.io.DataOutputstr - a string to be written.
java.io.IOException - if an I/O error occurs.public void setBinaryDataFormat(BinaryDataFormat bdf)
bdf - the new file BinaryDataFormat objectpublic BinaryDataFormat getBinaryDataFormat()
public void readBooleans(boolean[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readDoubles(double[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readFloats(float[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readInts(int[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readLongs(long[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readLongDoubles(double[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readLongLongs(long[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readShorts(short[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readUnsignedShorts(short[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readUnsignedInts(int[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readUnsignedLongs(long[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void readUnsignedLongLongs(long[] values,
int nValues)
throws java.io.EOFException,
java.io.IOException
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.
values - the array of values to setnValues - the number of values to read
java.io.EOFException - if this stream reaches the end before
reading all the bytes
java.io.IOException - if an I/O error occurs
public void writeBooleans(boolean[] values,
int nValues)
throws java.io.IOException
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
public void writeDoubles(double[] values,
int nValues)
throws java.io.IOException
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.
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
public void writeFloats(float[] values,
int nValues)
throws java.io.IOException
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.
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
public void writeInts(int[] values,
int nValues)
throws java.io.IOException
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.
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
public void writeLongs(long[] values,
int nValues)
throws java.io.IOException
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.
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
public void writeShorts(short[] values,
int nValues)
throws java.io.IOException
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.
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
public void writeLongLongs(long[] values,
int nValues)
throws java.io.IOException
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.
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
public void writeLongDoubles(double[] values,
int nValues)
throws java.io.IOException
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.
values - the array of values to be writtennValues - the number of values to write
java.io.IOException - if an I/O error occurs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||