Java Reference
In-Depth Information
Display 10.21
Some Methods of the Class
RandomAccessFile
(part 2 of 3)
public final void
writeByte(
byte
b)
throws
IOException
Writes the
byte
b
to the file.
public final void
writeShort(
short
n)
throws
IOException
Writes the
short
n
to the file.
public final void
writeInt(
int
n)
throws
IOException
Writes the
int
n
to the file.
public final void
writeLong(
long
n)
throws
IOException
Writes the
long
n
to the file.
public final void
writeDouble(
double
d)
throws
IOException
Writes the
double
d
to the file.
public final void
writeFloat(
float
f)
throws
IOException
Writes the
float
f
to the file.
public final void
writeChar(
char
c)
throws
IOException
Writes the
char
c
to the file.
public final void
writeBoolean(
boolean
b)
throws
IOException
Writes the
boolean
b
to the file.
public final void
writeUTF(String s)
throws
IOException
Writes the
String
s
to the file.
public
int
read()
throws
IOException
Reads a byte of data from the file and returns it as an integer in the range 0 to 255.
public int
read(
byte
[] a)
throws
IOException
Reads
a.length
bytes of data from the file into the array of bytes
a
. Returns the number of bytes
read or -1 if the end of the file is encountered.
public final byte
readByte()
throws
IOException
Reads a
byte
value from the file and returns that value. If an attempt is made to read beyond the end
of the file, an
EOFException
is thrown.
public final short
readShort()
throws
IOException
Reads a
short
value from the file and returns that value. If an attempt is made to read beyond the
end of the file, an
EOFException
is thrown.