java - 如何选择 "My Documents"文件保存路径

标签 java file path save jfilechooser

我想这样做:

JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(System.getProperty(**MY DOCUMENTS PATH **)));

我想做的就是放置“我的文档”路径,它在不同的Windows版本中会改变,但我不知道该怎么做。

我无法使用“文字路径”,我需要一个相对路径,因为此应用程序将在所有 Windows 版本上运行,而我无法使用文字路径。

最佳答案

据我所知,这是所有 Windows 版本的“我的文档”路径:

String myDocumentPath = System.getProperty("user.home") + "Documents";

关于java - 如何选择 "My Documents"文件保存路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28743902/

相关文章:

c++ - 警告 : format ‘%d’ expects argument of type ‘int *’ , 但参数 5 的类型为 ‘int’ [-Wformat=]

.net - 如何在不丢失奇数字符的情况下读取文本文件?

gd库的php路径

java - 如何在二维数组上正确使用格式化程序?

java - 了解 Firebase 中的事务

java - 如何让 JavaFx Combobox 响应用户输入?

c# - 将音频录制到内存流中,然后将其保存到文件中

path - Yeoman/Grunt Usemin子文件夹

windows - msys git 和长路径

java - 使用 Java 复制文件