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