本文介绍了如何从内容类型获取文件扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Tika,并且我有特定内容类型的文件(不带扩展名),需要重命名以具有反映内容类型的扩展名.

I'm using Apache Tika, and I have files (without extension) of particular content type that need to be renamed to have extension that reflect the content type.

是否知道有什么我可以使用的东西,而不是根据内容类型名称从头开始编写的东西?

Any idea if there is something I could use instead of programming that from scratch based on content type names ?

推荐答案

您要查看文件tika-mimetypes.xml->查看tika的源代码,然后:

You want to look at file tika-mimetypes.xml -> check out tika's source code and :

org.apache.tika.mime.MimeTypesReader

     } else if (nodeElement.getTagName().equals(GLOB_TAG)) {
         boolean useRegex = Boolean.valueOf(nodeElement.getAttribute(ISREGEX_ATTR));
         types.addPattern(type, nodeElement.getAttribute(PATTERN_ATTR), useRegex);

然后您就可以机智

org.apache.tika.mime.MimeTypes

      private Patterns patterns = new Patterns(registry);

这篇关于如何从内容类型获取文件扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 03:30
查看更多