2012-08-02 43 views
1

我使用的是Java 7,NIO包而不是IO,但JFileChooser使用File类到getSelectedFile(),但在NIO中只有Path类。我如何在JFileChooser上使用NIO类?如何在Java 7中使用NIO和JFilechooser?

+1

你最好开始与官方[教程](http://docs.oracle.com/javase/tutorial/essential/io/ fileio.html)。这很容易遵循,并提供了很多有用的信息。 – jFrenetic 2012-08-02 06:43:16

回答

1
Path path = selectedFile.toPath(); 
+0

非常感谢您的回答 – srisar 2012-08-02 06:50:30

0

试试这个:

File file = Paths.get(URI).toFile(); 
+0

非常感谢回答 – srisar 2012-08-02 06:50:15

+0

@srisar欢迎您.. – 2012-08-02 06:50:49

2
yourPath = yourJFileChooser.getSelectedFile().toPath();