JFileChooser chooser = new JFileChooser();

try {
    // Create a File object containing the canonical path of the
    // desired directory
    File f = new File(new File(".").getCanonicalPath());

    // Set the current directory
} catch (IOException e) {

// The following method call sets the current directory to the home directory

// Show the dialog; wait until dialog is closed

// Get the current directory
File curDir = chooser.getCurrentDirectory();

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.