首页 > 其他 > 详细

打开文件的功能代码 JFileChooser

时间:2017-10-11 10:21:30      阅读:247      评论:0      收藏:0      [点我收藏+]

 

//最近很迷茫,什么都没有学到,也感觉很疲惫。找到一个很好的GUI控件,跟大家分享一下

import javax.swing.JFileChooser;

public class yydm {
public static void main(String args[]){

JFileChooser jFileChooser = new JFileChooser();
int i = jFileChooser.showOpenDialog(null);
//打开文件:其中0表示打开,1表示没打开,好像跟Boolean型是相反的.
if(i== jFileChooser.APPROVE_OPTION){
String path = jFileChooser.getSelectedFile().getAbsolutePath();
String name = jFileChooser.getSelectedFile().getName();
System.out.println("当前文件路径:"+path+";\n当前文件名:"+name);
}else{
System.out.println("没有选中文件");
}
}

}

打开文件的功能代码 JFileChooser

原文:http://www.cnblogs.com/qiqisx/p/7648722.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!