是否有与 unix 中的 file 命令等效的 java 库 [英] Is there a java library equivalent to file command in unix

查看:26
本文介绍了是否有与 unix 中的 file 命令等效的 java 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有类似unix命令file的java库?

Is there any java library that is similar to unix's command file?

即:

$ file somepicture.png
somepicture.png PNG image, 805 x 292, 8-bit/color RGB, non-interlaced

file 命令真是个好工具.我需要一些可以告诉我文件是否真的是我想要的东西.(即图片、文档等)

The file command is such a nice tool. I need something that can tell me if the file is really what I want it to be. (ie a picture, document etc)

我知道我可以运行命令 file,但我正在寻找一个 java 库,而不是运行实际的 unix 命令.

I know I can run the command file, but I am looking for a java library, not running the actual unix command.

推荐答案

快速谷歌搜索(对于公认的非显而易见的)"java魔术文件检测" 带来了一篇相当漂亮的文章,"Get the Mime Type from a File" 建议您使用以下选项之一:

A quick google search (for the admittedly non-obvious) "java magic file detection" brings up a fairly nice looking article, "Get the Mime Type from a File" which suggests you use one of the following:

这篇关于是否有与 unix 中的 file 命令等效的 java 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆