小编Kun*_*dan的帖子

通过JFileChooser获取所选文件的类型

我正在编写一个程序来从中选择文件JFileChooser.如何获取文件类型(例如,该文件是" .dxt "或" .dtml "的" .dat "等.)

我有以下代码.我应该怎么添加额外的线?

JFileChooser choice = new JFileChooser();
int option = choice.showOpenDialog(this);
if (option == JFileChooser.APPROVE_OPTION)
{
     String path=choice.getSelectedFile().getAbsolutePath();
     String filename=choice.getSelectedFile().getName();
     System.out.println(path);
     listModel.addElement(path);
     System.out.println(filename);
}
Run Code Online (Sandbox Code Playgroud)

java swing jfilechooser

2
推荐指数
1
解决办法
6000
查看次数

标签 统计

java ×1

jfilechooser ×1

swing ×1