我正在编写一个程序来从中选择文件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)