As an alternative, we can use a method provided by the JFileChooser class.
import javax.swing.JFileChooser;
javax.swing.filechooser.FileSystemView;
public class GetMyDocuments {
public static void main(String args[]) {
JFileChooser fr = new JFileChooser();
FileSystemView fw = fr.getFileSystemView();
System.out.println(fw.getDefaultDirectory());
}
}
Written and compiled by Réal Gagnon ©1998-2010
[ home ]