RandomAccessFile (Java Platform SE 7 ) (original) (raw)
Modifier and Type
Method and Description
void
**[close](../../java/io/RandomAccessFile.html#close%28%29)**()
Closes this random access file stream and releases any system resources associated with the stream.
[FileChannel](../../java/nio/channels/FileChannel.html "class in java.nio.channels")
**[getChannel](../../java/io/RandomAccessFile.html#getChannel%28%29)**()
Returns the unique FileChannel object associated with this file.
[FileDescriptor](../../java/io/FileDescriptor.html "class in java.io")
**[getFD](../../java/io/RandomAccessFile.html#getFD%28%29)**()
Returns the opaque file descriptor object associated with this stream.
long
**[getFilePointer](../../java/io/RandomAccessFile.html#getFilePointer%28%29)**()
Returns the current offset in this file.
long
**[length](../../java/io/RandomAccessFile.html#length%28%29)**()
Returns the length of this file.
int
**[read](../../java/io/RandomAccessFile.html#read%28%29)**()
Reads a byte of data from this file.
int
**[read](../../java/io/RandomAccessFile.html#read%28byte[]%29)**(byte[] b)
Reads up to b.length
bytes of data from this file into an array of bytes.
int
**[read](../../java/io/RandomAccessFile.html#read%28byte[],%20int,%20int%29)**(byte[] b, int off, int len)
Reads up to len
bytes of data from this file into an array of bytes.
boolean
**[readBoolean](../../java/io/RandomAccessFile.html#readBoolean%28%29)**()
Reads a boolean
from this file.
byte
**[readByte](../../java/io/RandomAccessFile.html#readByte%28%29)**()
Reads a signed eight-bit value from this file.
char
**[readChar](../../java/io/RandomAccessFile.html#readChar%28%29)**()
Reads a character from this file.
double
**[readDouble](../../java/io/RandomAccessFile.html#readDouble%28%29)**()
Reads a double
from this file.
float
**[readFloat](../../java/io/RandomAccessFile.html#readFloat%28%29)**()
Reads a float
from this file.
void
**[readFully](../../java/io/RandomAccessFile.html#readFully%28byte[]%29)**(byte[] b)
Reads b.length
bytes from this file into the byte array, starting at the current file pointer.
void
**[readFully](../../java/io/RandomAccessFile.html#readFully%28byte[],%20int,%20int%29)**(byte[] b, int off, int len)
Reads exactly len
bytes from this file into the byte array, starting at the current file pointer.
int
**[readInt](../../java/io/RandomAccessFile.html#readInt%28%29)**()
Reads a signed 32-bit integer from this file.
[String](../../java/lang/String.html "class in java.lang")
**[readLine](../../java/io/RandomAccessFile.html#readLine%28%29)**()
Reads the next line of text from this file.
long
**[readLong](../../java/io/RandomAccessFile.html#readLong%28%29)**()
Reads a signed 64-bit integer from this file.
short
**[readShort](../../java/io/RandomAccessFile.html#readShort%28%29)**()
Reads a signed 16-bit number from this file.
int
**[readUnsignedByte](../../java/io/RandomAccessFile.html#readUnsignedByte%28%29)**()
Reads an unsigned eight-bit number from this file.
int
**[readUnsignedShort](../../java/io/RandomAccessFile.html#readUnsignedShort%28%29)**()
Reads an unsigned 16-bit number from this file.
[String](../../java/lang/String.html "class in java.lang")
**[readUTF](../../java/io/RandomAccessFile.html#readUTF%28%29)**()
Reads in a string from this file.
void
**[seek](../../java/io/RandomAccessFile.html#seek%28long%29)**(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
void
**[setLength](../../java/io/RandomAccessFile.html#setLength%28long%29)**(long newLength)
Sets the length of this file.
int
**[skipBytes](../../java/io/RandomAccessFile.html#skipBytes%28int%29)**(int n)
Attempts to skip over n
bytes of input discarding the skipped bytes.
void
**[write](../../java/io/RandomAccessFile.html#write%28byte[]%29)**(byte[] b)
Writes b.length
bytes from the specified byte array to this file, starting at the current file pointer.
void
**[write](../../java/io/RandomAccessFile.html#write%28byte[],%20int,%20int%29)**(byte[] b, int off, int len)
Writes len
bytes from the specified byte array starting at offset off
to this file.
void
**[write](../../java/io/RandomAccessFile.html#write%28int%29)**(int b)
Writes the specified byte to this file.
void
**[writeBoolean](../../java/io/RandomAccessFile.html#writeBoolean%28boolean%29)**(boolean v)
Writes a boolean
to the file as a one-byte value.
void
**[writeByte](../../java/io/RandomAccessFile.html#writeByte%28int%29)**(int v)
Writes a byte
to the file as a one-byte value.
void
**[writeBytes](../../java/io/RandomAccessFile.html#writeBytes%28java.lang.String%29)**([String](../../java/lang/String.html "class in java.lang") s)
Writes the string to the file as a sequence of bytes.
void
**[writeChar](../../java/io/RandomAccessFile.html#writeChar%28int%29)**(int v)
Writes a char
to the file as a two-byte value, high byte first.
void
**[writeChars](../../java/io/RandomAccessFile.html#writeChars%28java.lang.String%29)**([String](../../java/lang/String.html "class in java.lang") s)
Writes a string to the file as a sequence of characters.
void
**[writeDouble](../../java/io/RandomAccessFile.html#writeDouble%28double%29)**(double v)
Converts the double argument to a long
using thedoubleToLongBits
method in class Double
, and then writes that long
value to the file as an eight-byte quantity, high byte first.
void
**[writeFloat](../../java/io/RandomAccessFile.html#writeFloat%28float%29)**(float v)
Converts the float argument to an int
using thefloatToIntBits
method in class Float
, and then writes that int
value to the file as a four-byte quantity, high byte first.
void
**[writeInt](../../java/io/RandomAccessFile.html#writeInt%28int%29)**(int v)
Writes an int
to the file as four bytes, high byte first.
void
**[writeLong](../../java/io/RandomAccessFile.html#writeLong%28long%29)**(long v)
Writes a long
to the file as eight bytes, high byte first.
void
**[writeShort](../../java/io/RandomAccessFile.html#writeShort%28int%29)**(int v)
Writes a short
to the file as two bytes, high byte first.
void
**[writeUTF](../../java/io/RandomAccessFile.html#writeUTF%28java.lang.String%29)**([String](../../java/lang/String.html "class in java.lang") str)
Writes a string to the file usingmodified UTF-8 encoding in a machine-independent manner.