Microsoft SDK for Java

openRandomAccessFile

This method of the UserFileDialog Class displays a dialog box that allows the user to open a file for random access. If the user selects a file, then a FileInputStream object for that file is returned. If the user cancels the dialog box, null is returned. To determine the name of the file that was opened, you can use the getFileName method.

Syntax

public synchronized RandomAccessFile openRandomAccessFile( String mode) throws IOException;

Return Value

Returns a RandomAccessFile object if the user selects a file or returns null if the user cancels the dialog box.

Parameters

mode The mode to open the file in. If mode is "r", the file is opened in read-only mode. If mode is "rw", the file is opened in read-write mode.

Exceptions

IllegalArgumentException if the mode argument is not equal to "r" or to "rw".

SecurityException if the caller does not have permission to initiate user-directed file I/O.

IOException if an I/O error occurs while attempting to open the file.

© 1999 Microsoft Corporation. All rights reserved. Terms of use.