Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the user's 'Documents' folder with Java in OS X?

Tags:

I'd like to create a directory in the user's 'Documents' folder, but so far I've only found out how to get the user's home directory:

javax.swing.JFileChooser fr = new javax.swing.JFileChooser();
javax.swing.filechooser.FileSystemView fw = fr.getFileSystemView();
this.userDirectory = fw.getDefaultDirectory();

In Windows the above code returns the 'My Documents' directory, which is great, that's where the new documents are supposed to go. On OS X it only returns the home directory.

Adding 'Documents' to the returned path would cause problems with localization.

How can I do this?