File file =null;
JFileChooser chooser = new JFileChooser();
int state = chooser.showDialog(this,"打开");
String fileName="";
if(state == JFileChooser.APPROVE_OPTION){
file = chooser.getSelectedFile();//得到文件
fileName = file.getPath();
}
JFileChooser chooser = new JFileChooser();
int state = chooser.showDialog(this,"打开");
String fileName="";
if(state == JFileChooser.APPROVE_OPTION){
file = chooser.getSelectedFile();//得到文件
fileName = file.getPath();
}
file =openfiledialog.getSelectedFile().getPath();
得到你选中文件的路径
如过只想得到文件名去掉getPath()就可以了