RandomAccessFile.RandomAccessFile

RandomAccessFile.RandomAccessFile

Class Overview | Class Members | This Package | All Packages

Syntax 1
public RandomAccessFile( String name, String mode ) throws IOException
Parameters
name
the system-dependent filename.
mode
the access mode.
Description
Creates a random access file stream to read from, and optionally to write to, a file with the specified name.

The mode argument must either be equal to "r" or "rw", indicating either to open the file for input or for both input and output.

Exceptions
IllegalArgumentException if the mode argument is not equal to "r" or to "rw".
Exceptions
IOException if an I/O error occurs.
Exceptions
SecurityException if a security manager exists, its checkRead method is called with the name argument to see if the application is allowed read access to the file. If the mode argument is equal to "rw", its checkWrite method also is called with the name argument to see if the application is allowed write access to the file. Either of these may result in a security exception.
See Also
SecurityException, checkRead



Syntax 2
public RandomAccessFile( File file, String mode ) throws IOException
Parameters
file
the file object.
mode
the access mode.
Description
Creates a random access file stream to read from, and optionally to write to, the file specified by the File argument.

The mode argument must either be equal to "r" or to "rw", indicating either to open the file for input, or for both input and output, respectively.

Exceptions
IllegalArgumentException if the mode argument is not equal to "r" or to "rw".
Exceptions
IOException if an I/O error occurs.
Exceptions
SecurityException if a security manager exists, its checkRead method is called with the pathname of the File argument to see if the application is allowed read access to the file. If the mode argument is equal to "rw", its checkWrite method also is called with the pathname to see if the application is allowed write access to the file.
See Also
getPath, checkRead