What is the problem?!?

this is a pretty easy program to understand:

import javax.swing.*;

import java.io.*;

publicclass getDir

{

publicstaticvoid main(String[] args)

{

JFileChooser FileChooser =new JFileChooser();

JFrame Frame =new JFrame();

File curDir;

FileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

FileChooser.showSaveDialog(Frame);

curDir = FileChooser.getCurrentDirectory();

System.out.println(curDir);

System.exit(0);

}

}

So why when I click save at this directory:

<img src="http://i14.photobucket.com/albums/a327/dekutree1/Directory.jpg">

Do i get the output:

<img src="http://i14.photobucket.com/albums/a327/dekutree1/output.jpg">

Notice how it cuts off the last folder. Any way to fix this?

thanks, lateralus

[1271 byte] By [Lateralus01a] at [2007-11-26 22:19:35]
# 1

The getCurrentDirectory() method returns the directory you chose the file from. In other words, the parent directory of the directory you chose. On the other hand, the getSelectedFile() method returns the actual directory you chose.

The API documentation even shows an example of this, besides documenting the methods in question. Yes, I know, you weren't thinking straight and didn't realize that directories are files too.

DrClapa at 2007-7-10 11:15:44 > top of Java-index,Java Essentials,New To Java...