level 1
候良意饿哼31
楼主
String path = jFileChooser.getSelectedFile().getPath();
String name = jFileChooser.getSelectedFile().getName();
上述代码中,jFileChooser是文件选择器的一个对象,用它来获取打开文件的路径以及名字。
假定获取到的path和name为:
path = “C:\Users\Administrator\Desktop\数据\HD1-H34-5195.0(9探头数据).wfl”
name = “HD1-H34-5195.0(9探头数据).wfl”
然后我想实现去掉里面的部分内容,如下所示:
path = “C:\Users\Administrator\Desktop\数据\”
name = “HD1-H34-5195.0(9探头数据)”
就是每次都是把后面的指定内容去掉(也就是只把path的路径获取到,而不要文件名字及后面的东西;同样的是把name的名字获取到,而不要后缀格式)。该如何实现呢?
2014年05月05日 05点05分
1
String name = jFileChooser.getSelectedFile().getName();
上述代码中,jFileChooser是文件选择器的一个对象,用它来获取打开文件的路径以及名字。
假定获取到的path和name为:
path = “C:\Users\Administrator\Desktop\数据\HD1-H34-5195.0(9探头数据).wfl”
name = “HD1-H34-5195.0(9探头数据).wfl”
然后我想实现去掉里面的部分内容,如下所示:
path = “C:\Users\Administrator\Desktop\数据\”
name = “HD1-H34-5195.0(9探头数据)”
就是每次都是把后面的指定内容去掉(也就是只把path的路径获取到,而不要文件名字及后面的东西;同样的是把name的名字获取到,而不要后缀格式)。该如何实现呢?