我正在尝试检测我打开的文件是否是 HTML 文件。
我已经尝试过这个:
try {
String file = fileName.getCanonicalPath();
if (file.endsWith(".htm") | file.endsWith(".html")) {
}
} catch (IOException e) {
e.printStackTrace();
}
但file.endsWith();
似乎没有检测到任何东西。这fileName
是我正在打开的文件。让我知道是否必须发布用于打开文件的代码。
提前致谢。