I ve创建了一个JFileChooser,我用来找到一个目录,以保存档案。
saveChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
saveChooser.showSaveDialog(null);
String exportPath = saveChooser.getCurrentDirectory() + "\exportedData.txt";
System.out.println(exportPath);
(我然后将出口食品用于我的档案作者)
When I choose C:Users me Eclipseworkspace project files in the JFileChooser the output is C:Users me Eclipseworkspace project exportedData.txt
I ve tried saving to multiple locations. It seems like it always drops the last directory. However, when I select root C: it uses My Documents which is the default I suppose. I know this probably isn t the best way to save a file and opens up to a few bugs, sorry. (The file name and extension is set in code).