CurDir

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
    chooser.setCurrentDirectory(f);
} catch (IOException e) {
}

// The following method call sets the current directory to the home directory
chooser.setCurrentDirectory(null);

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

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