All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jnfs.RemoteRandomAccessFile

java.lang.Object
   |
   +----jnfs.RemoteRandomAccessFile

public class RemoteRandomAccessFile
extends Object
implements DataInput, DataOutput, Serializable
An interface to a RandomAccessFile on the FileServer. Although it is not a descendant of RandomAccessFile, this class uses the same semantics.

Most of this code for this class was borrowed from sun's RandomAccessFile.java (since java doesn't support multiple inheritance).

Version:
$Id: RemoteRandomAccessFile.java,v 2.13 1997/05/20 17:59:39 mjr Exp $
Author:
Michael John Radwin
See Also:
FileServer, RandomAccessFile

Method Index

 o close()
Closes this random access file and releases any system resources associated with the file.
 o finalize()
Ensures that the close method of this random access file is called when there are no more references to it.
 o getFilePointer()
Returns the current offset in this file.
 o length()
Returns the length of this file.
 o read()
Reads a byte of data from this file.
 o read(byte[])
Reads up to b.length bytes of data from this file into an array of bytes.
 o read(byte[], int, int)
Reads up to len bytes of data from this file into an array of bytes.
 o readBoolean()
Reads a boolean from this file.
 o readByte()
Reads a signed 8-bit value from this file.
 o readChar()
Reads a Unicode character from this file.
 o readDouble()
Reads a double from this file.
 o readFloat()
Reads a float from this file.
 o readFully(byte[])
Reads b.length bytes from this file into the byte array.
 o readFully(byte[], int, int)
Reads exactly len bytes from this file into the byte array.
 o readInt()
Reads a signed 32-bit integer from this file.
 o readLine()
Reads the next line of text from this file.
 o readLong()
Reads a signed 64-bit integer from this file.
 o readShort()
Reads a signed 16-bit number from this file.
 o readUnsignedByte()
Reads an unsigned 8-bit number from this file.
 o readUnsignedShort()
Reads an unsigned 16-bit number from this file.
 o readUTF()
Reads in a string from this file.
 o seek(long)
Sets the offset from the beginning of this file at which the next read or write occurs.
 o skipBytes(int)
Skips exactly n bytes of input.
 o write(byte[])
Writes b.length bytes from the specified byte array starting at offset off to this file.
 o write(byte[], int, int)
Writes len bytes from the specified byte array starting at offset off to this file.
 o write(int)
Writes the specified byte to this file.
 o writeBoolean(boolean)
Writes a boolean to the file as a 1-byte value.
 o writeByte(int)
Writes a byte to the file as a 1-byte value.
 o writeBytes(String)
Writes the string to the file as a sequence of bytes.
 o writeChar(int)
Writes a char to the file as a 2-byte value, high byte first.
 o writeChars(String)
Writes a string to the file as a sequence of characters.
 o writeDouble(double)
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the file as an 8-byte quantity, high byte first.
 o writeFloat(float)
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the file as a 4-byte quantity, high byte first.
 o writeInt(int)
Writes an int to the file as four bytes, high byte first.
 o writeLong(long)
Writes a long to the file as eight bytes, high byte first.
 o writeShort(int)
Writes a short to the file as two bytes, high byte first.
 o writeUTF(String)
Writes a string to the file using UTF-8 encoding in a machine-independent manner.

Methods

 o getFilePointer
 public long getFilePointer() throws 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: IOException
if an I/O error occurs.
 o seek
 public synchronized void seek(long pos) throws IOException
Sets the offset from the beginning of this file at which the next read or write occurs.

Parameters:
pos - the absolute position.
Throws: IOException
if an I/O error occurs.
 o length
 public long length() throws IOException
Returns the length of this file.

Returns:
the length of this file.
Throws: IOException
if an I/O error occurs.
 o read
 public synchronized int read() throws IOException
Reads a byte of data from this file.

Returns:
the next byte of data, or -1 if the end of the file is reached.
Throws: IOException
if an I/O error occurs.
See Also:
read
 o read
 public synchronized int read(byte b[],
                              int off,
                              int len) throws IOException
Reads up to len bytes of data from this file into an array of bytes.

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: IOException
if an I/O error occurs.
See Also:
read
 o read
 public synchronized int read(byte b[]) throws IOException
Reads up to b.length bytes of data from this file into an array of bytes.

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: IOException
if an I/O error occurs.
See Also:
read
 o readFully
 public synchronized void readFully(byte b[],
                                    int off,
                                    int len) throws IOException
Reads exactly len bytes from this file into the byte array.

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: EOFException
if this file reaches the end before reading all the bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readFully
 o readFully
 public synchronized void readFully(byte b[]) throws IOException
Reads b.length bytes from this file into the byte array.

Parameters:
b - the buffer into which the data is read.
Throws: EOFException
if this file reaches the end before reading all the bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readFully
 o skipBytes
 public int skipBytes(int n) throws IOException
Skips exactly n bytes of input.

Parameters:
n - the number of bytes to be skipped.
Returns:
the number of bytes skipped, which is always n.
Throws: EOFException
if this file reaches the end before skipping all the bytes.
Throws: IOException
if an I/O error occurs.
See Also:
skipBytes
 o readBoolean
 public boolean readBoolean() throws IOException
Reads a boolean from this file.

Returns:
the boolean value read.
Throws: EOFException
if this file has reached the end.
Throws: IOException
if an I/O error occurs.
See Also:
readBoolean
 o readByte
 public byte readByte() throws IOException
Reads a signed 8-bit value from this file.

Returns:
the next byte of this file as a signed 8-bit byte.
Throws: EOFException
if this file has reached the end.
Throws: IOException
if an I/O error occurs.
See Also:
readByte
 o readUnsignedByte
 public int readUnsignedByte() throws IOException
Reads an unsigned 8-bit number from this file.

Returns:
the next byte of this file, interpreted as an unsigned 8-bit number.
Throws: EOFException
if this file has reached the end.
Throws: IOException
if an I/O error occurs.
See Also:
readUnsignedByte
 o readShort
 public short readShort() throws IOException
Reads a signed 16-bit number from this file.

Returns:
the next two bytes of this file, interpreted as a signed 16-bit number.
Throws: EOFException
if this file reaches the end before reading two bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readShort
 o readUnsignedShort
 public int readUnsignedShort() throws IOException
Reads an unsigned 16-bit number from this file.

Returns:
the next two bytes of this file, interpreted as an unsigned 16-bit integer.
Throws: EOFException
if this file reaches the end before reading two bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readUnsignedShort
 o readChar
 public char readChar() throws IOException
Reads a Unicode character from this file.

Returns:
the next two bytes of this file as a Unicode character.
Throws: EOFException
if this file reaches the end before reading two bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readChar
 o readInt
 public int readInt() throws IOException
Reads a signed 32-bit integer from this file.

Returns:
the next four bytes of this file, interpreted as an int.
Throws: EOFException
if this file reaches the end before reading four bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readInt
 o readLong
 public long readLong() throws IOException
Reads a signed 64-bit integer from this file.

Returns:
the next eight bytes of this file, interpreted as a long.
Throws: EOFException
if this file reaches the end before reading eight bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readLong
 o readFloat
 public float readFloat() throws IOException
Reads a float from this file.

Returns:
the next four bytes of this file, interpreted as a float.
Throws: EOFException
if this file reaches the end before reading four bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readInt, intBitsToFloat, readFloat
 o readDouble
 public double readDouble() throws IOException
Reads a double from this file.

Returns:
the next eight bytes of this file, interpreted as a double.
Throws: EOFException
if this file reaches the end before reading eight bytes.
Throws: IOException
if an I/O error occurs.
See Also:
readLong, longBitsToDouble, readDouble
 o readLine
 public String readLine() throws IOException
Reads the next line of text from this file.

Returns:
the next line of text from this file.
Throws: IOException
if an I/O error occurs.
See Also:
readLine
 o readUTF
 public String readUTF() throws IOException
Reads in a string from this file.

Returns:
a Unicode string.
Throws: EOFException
if this file reaches the end before reading all the bytes.
Throws: IOException
if an I/O error occurs.
Throws: UTFDataFormatException
if the bytes do not represent valid UTF-8 encoding of a Unicode string.
See Also:
readUnsignedShort, readUTF
 o write
 public synchronized void write(int b) throws IOException
Writes the specified byte to this file.

Parameters:
b - the byte to be written.
Throws: IOException
if an I/O error occurs.
See Also:
write
 o write
 public synchronized void write(byte b[],
                                int off,
                                int len) throws IOException
Writes len bytes from the specified byte array starting at offset off to this file.

Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws: IOException
if an I/O error occurs.
See Also:
write
 o write
 public synchronized void write(byte b[]) throws IOException
Writes b.length bytes from the specified byte array starting at offset off to this file.

Parameters:
b - the data.
Throws: IOException
if an I/O error occurs.
See Also:
write
 o writeBoolean
 public void writeBoolean(boolean v) throws IOException
Writes a boolean to the file as a 1-byte value.

Parameters:
v - a boolean value to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeBoolean
 o writeByte
 public void writeByte(int v) throws IOException
Writes a byte to the file as a 1-byte value.

Parameters:
v - a byte value to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeByte
 o writeShort
 public void writeShort(int v) throws IOException
Writes a short to the file as two bytes, high byte first.

Parameters:
v - a short to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeShort
 o writeChar
 public void writeChar(int v) throws IOException
Writes a char to the file as a 2-byte value, high byte first.

Parameters:
v - a char value to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeChar
 o writeInt
 public void writeInt(int v) throws IOException
Writes an int to the file as four bytes, high byte first.

Parameters:
v - an int to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeInt
 o writeLong
 public void writeLong(long v) throws IOException
Writes a long to the file as eight bytes, high byte first.

Parameters:
v - a long to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeLong
 o writeFloat
 public void writeFloat(float v) throws IOException
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the file as a 4-byte quantity, high byte first.

Parameters:
v - a float value to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeFloat
 o writeDouble
 public void writeDouble(double v) throws IOException
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the file as an 8-byte quantity, high byte first.

Parameters:
v - a double value to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeDouble
 o writeBytes
 public void writeBytes(String s) throws 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.

Parameters:
s - a string of bytes to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeBytes
 o writeChars
 public void writeChars(String s) throws 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.

Parameters:
s - a String value to be written.
Throws: IOException
if an I/O error occurs.
See Also:
writeChars
 o writeUTF
 public void writeUTF(String str) throws IOException
Writes a string to the file using UTF-8 encoding in a machine-independent manner.

Parameters:
str - a string to be written.
Throws: IOException
if an I/O error occurs.
Throws: UTFDataFormatException
if the string is too long to write a valid UTF-8 encoding.
See Also:
writeUTF
 o close
 public synchronized void close() throws IOException
Closes this random access file and releases any system resources associated with the file.

Throws: IOException
if an I/O error occurs.
 o finalize
 protected void finalize() throws IOException
Ensures that the close method of this random access file is called when there are no more references to it.

Throws: IOException
if an I/O error occurs.
Overrides:
finalize in class Object
See Also:
close

All Packages  Class Hierarchy  This Package  Previous  Next  Index