以下這幾行幫助我瀏覽文件並將文件內容存儲到myFile
變量中?使用JFileChooser選擇文件
另外,有人可以告訴我以下是什麼意思?
JFrame frame = null;
和
(System.getProperty("user.dir")
代碼:
JFrame frame = null;
JFileChooser fChoose = new JFileChooser(System.getProperty("user.dir"));
int returnVal = fChoose.showOpenDialog(frame);
File myFile = fChoose.getSelectedFile();
如果您無法自行回答你的問題,你應該閱讀[this](http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html)。 – Qiu
'(System.getProperty(「user.dir」)'這意味着代碼的作者顯然不能很好地理解'JFileChooser',它**默認**到'user.dir'。請注意['JFileChooser'](http://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html)的Java文檔是開始回答此問題的好地方。 –
是你想存儲的文件內容是否包含文本? – cdMinix