CurFile

JFileChooser chooser = new JFileChooser();

// Set the current directory to the application's current directory
try {
    // Create a File object containing the canonical path of the
    // desired file
    File f = new File(new File("filename.txt").getCanonicalPath());

    // Set the selected file
    chooser.setSelectedFile(f);
} catch (IOException e) {
}

// Show the dialog; wait until dialog is closed
chooser.showOpenDialog(frame);

// Get the currently selected file
File curFile = chooser.getSelectedFile();

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.