Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何找到文件的类型?我正在编写代码来查找 unix 系统上的文件是否是图像文件?
可能有人更改了扩展名。
提前致谢。
使用file命令:
file
file <name of file>
Java 7Files.probeContentType(Path path)可以探测文件的内容类型。有关详细信息,请参阅 API。
Files.probeContentType(Path path)