Java Reference
In-Depth Information
public void
setLength(
long
newLength)
throws
IOException
Sets the length of this fi le.
If the present length of the fi le as returned by the
length
method is greater than the
newLength
argument, then the fi le will be truncated. In this case, if the fi le pointer location as
returned by the
getFilePointer
method is greater than
newLength
, then after this method
returns, the fi le pointer location will be equal to
newLength
.
If the present length of the fi le as returned by the
length
method is smaller than
newLength
,
then the fi le will be extended. In this case, the contents of the extended portion of the fi le are
not defi ned.
public long
getFilePointer()
throws
IOException
Returns the current location of the fi le pointer. Locations are numbered starting with
0
.
public long
length()
throws
IOException
Returns the length of the fi le.
public int
read()
throws
IOException
Reads a byte of data from the fi le and returns it as an integer in the range 0 to 255.
public int
read(
byte
[] a)
throws
IOException
Reads up to
a.length
bytes of data from the fi le into the array of bytes. Returns the total
number of bytes read or -1 if the end of the fi le is reached.
public final boolean
readBoolean()
throws
IOException
Reads a
boolean
value from the fi le and returns that value.
If an attempt is made to read beyond the end of the fi le, an
EOFException
is thrown.
public final byte
readByte()
throws
IOException
Reads a
byte
value from the fi le and returns that value.
If an attempt is made to read beyond the end of the fi le, an
EOFException
is thrown.
public final char
readChar()
throws
IOException
Reads a
char
value from the fi le and returns that value.
If an attempt is made to read beyond the end of the fi le, an
EOFException
is thrown.
public final double
readDouble()
throws
IOException
Reads a
double
value from the fi le and returns that value.
If an attempt is made to read beyond the end of the fi le, an
EOFException
is thrown.
public final float
readFloat()
throws
IOException
Reads a
float
value from the fi le and returns that value.
If an attempt is made to read beyond the end of the fi le, an
EOFException
is thrown.