使用Java代码查找文件类型? [英] Finding File Type Using Java Code?

查看:151
本文介绍了使用Java代码查找文件类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

i在我的主目录中有一个名为sxase的文件。检查属性我发现文件类型是.mp4。我正在寻找一个可以的java代码告诉我文件名sxase的扩展名。当我正在处理涉及此代码实现的项目时,我不想要任何工具,如TRID等

感谢提前

hello,
i have a file named "sxase" in my home directory.on checking the properties i find that the file type is ".mp4".i am looking for a java code that can tell me the extension for the file name "sxase".As i am working on the project that involves implementation of this code too i dont want any tools such as "TRID" etc
THANKS IN ADVANCE

推荐答案

文件类型只是名称上的几个字母,例如thistextfile。的txt 的。除了对系统用户有用的视觉辅助之外,它没有任何实际意义。如果要在Windows资源管理器中显示所有类型,请在工具菜单项中选择文件夹选项,然后取消选中选择标题为隐藏已知文件类型的扩展名。要获取Java程序中的信息,您需要获取目录中所有文件的列表,并将扩展字段与路径名分开。
File type is just an extra few letters on the name, e.g. thistextfile.txt. It has no real meaning beyond being a useful visual aid for the system user. If you want to show all types in Windows explorer then select the Folder options in the Tools menu item, and uncheck the selector titled "Hide extensions for known file types". To get the information in a Java program you would need to get a list of all the files in your directory and separate the extension field from the path name.


以识别我们的文件类型必须知道文件的MIME类型。在浏览java api时,我找到了javax.activation.FileTypeMap。这个类有方法,通过提供文件对象,它返回文件mime类型。



看见这可以满足你的要求。



问候,

Panduranga。
to identify the type of file we must know the MIME Type of the file . While going through the java api i found javax.activation.FileTypeMap. This class has methods, by providing the file object it return the file mime type.

See can this suffice you requirement.

Regards,
Panduranga.


这篇关于使用Java代码查找文件类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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