English 中文(简体)
Can t从JFileChooser获得正确档案途径
原标题:Can t get the correct file path from JFileChooser

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).

最佳回答

我猜测,你想要拯救Chooser.getS selectedFile(),在这种情况下,选定的档案实际上是一份目录。 希望是正确的,是徒劳的。

问题回答

暂无回答




相关问题
Swing: JFileChooser with favorites?

I m working on an application which needs to select files. JFileChooser is a great start, but I need to augment it. I can start it at one particular directory with JFileChooser.setCurrentDirectory(), ...

Implementation of file "save" like Notepad

I want to create a text editor (using java/swing) like notepad. For this I need the implementation of saving file. mean if the user clicks on "save" first time then the dialog should appear for taking ...

JFile chooser window?? How do I filter files?

In NetBeans, there is an object called a JFileChooser. I wanted to ask how you can set up a filter in order to just show files that have a .wds extension. .wds is an extension I use in my program.

java filechooser

I am working on a project, in java, where the user has to choose a file to be uploaded through a jfilechooser. Is there anyway to make the textfield readonly so that you can only choose files by ...

JFileChooser browsing a remote file system

I am trying to Implement a JFileChooser that allows a user to select files on a remote system via ftp. Everything I ve read says this can be accomplished by extending FileSystemView so that all the ...

热门标签