标签: java file unix
如何查找文件类型? 我正在编写一个代码来查找unix系统上的文件是否是图像文件?
可能存在某人更改了扩展名的可能性。
提前致谢。
答案 0 :(得分:1)
使用file命令:
file
file <name of file>
答案 1 :(得分:0)
Java 7具有Files.probeContentType(Path path),用于探测文件的内容类型。有关详细信息,请参阅API。
Files.probeContentType(Path path)