Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis Package
Package com.ms.io   Previous This
Package

 


Class UserFileDialog

public final class UserFileDialog
{
  // Constructors
  public UserFileDialog(Frame parent,String title);

  // Methods
  public String getFileName();
  public synchronized FileInputStream openFileForReading()
        throws IOException;
  public synchronized FileOutputStream openFileForWriting()
        throws IOException;
  public synchronized RandomAccessFile openRandomAccessFile(
        String mode) throws IOException;
}

This class provides methods for creating and displaying dialog boxes that can open files for reading, writing, and random access.

Constructors

UserFileDialog

public UserFileDialog(Frame parent,String title);

Creates a UserFileDialog object that represents a file dialog box. After creating the UserFileDialog object, you can use one of the following methods to display the dialog box and open a file:

ParameterDescription
parent The owner of the file dialog box.
title The title of the file dialog box.

Methods

getFileName

public String getFileName();

Retrieves the name of the last file opened with a dialog box if a successful file open operation has been performed with the dialog box. This method returns null if the dialog box has never been used to open a file or if the last attempt to open a file with the dialog box failed for any reason.

Return Value:

Returns the name of the last file successfully opened with this dialog box; returns null if the last attempt failed or if the dialog box has never been used to open a file.

openFileForReading

public synchronized FileInputStream openFileForReading() throws IOException;

Displays a dialog box that allows the user to open a file for reading. 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.

Return Value:

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

Exceptions:

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.

openFileForWriting

public synchronized FileOutputStream openFileForWriting()
        throws IOException;

Displays a dialog box that allows the user to open a file for writing. If the user selects a file, then a FileOutputStream 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.

Return Value:

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

Exceptions:

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.

openRandomAccessFile

public synchronized RandomAccessFile openRandomAccessFile(
        String mode) throws IOException;

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.

Return Value:

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

ParameterDescription
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.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.