文件内容提取:Apache Tika 2.9.2

提取各种文件的文本内容,offic image zip 等等...

Apache Tika 2.9.2 、 jdk8

基础 pom.xml

xml 复制代码
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core -->
<dependency>
    <groupId>org.apache.tika</groupId>
    <artifactId>tika-core</artifactId>
    <version>2.9.2</version>
</dependency>
<dependency>
    <groupId>org.apache.tika</groupId>
    <artifactId>tika-parsers-standard-package</artifactId>
    <version>2.9.2</version>
</dependency>

还需要用到的 pom.xml

xml 复制代码
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
</dependency>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.17.0</version>
</dependency>
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-compress</artifactId>
    <version>1.26.2</version>
</dependency>
  • 注意版本号,不然会出问题

java demo

java 复制代码
@Test
public void test() throws Exception {
    InputStream inputStream = Files.newInputStream(Paths.get("text.zip"));

    BodyContentHandler contentHandler = new BodyContentHandler(-1);
    Metadata metadata = new Metadata();
    ParseContext parseContext = new ParseContext();

    new AutoDetectParser()
            .parse(inputStream, contentHandler, metadata, parseContext);

	// 提取出来的内容
    System.out.println(contentHandler);
    System.out.println("-------------------------------------------");
    // 元数据信息
    String[] names = metadata.names();
    for (String name : names) {
        System.out.println(name + ":" + metadata.get(name));
    }
}
相关推荐
喂完待续2 小时前
【Tech Arch】Hive技术解析:大数据仓库的SQL桥梁
大数据·数据仓库·hive·hadoop·sql·apache
SelectDB2 小时前
5000+ 中大型企业首选的 Doris,在稳定性的提升上究竟花了多大的功夫?
大数据·数据库·apache
喂完待续15 小时前
Apache Hudi:数据湖的实时革命
大数据·数据仓库·分布式·架构·apache·数据库架构
数据爬坡ing2 天前
过程设计工具深度解析-软件工程之详细设计(补充篇)
大数据·数据结构·算法·apache·软件工程·软件构建·设计语言
运维行者_2 天前
使用Applications Manager进行 Apache Solr 监控
运维·网络·数据库·网络安全·云计算·apache·solr
皓空揽月2 天前
php+apache+nginx 更换域名
nginx·php·apache
求知若渴,虚心若愚。4 天前
高可用实战之Nginx + Apache篇
运维·nginx·apache
阿里云云原生5 天前
Apache RocketMQ EventBridge:为什么 GenAI 需要 EDA?
apache·rocketmq
沈健_算法小生6 天前
Apache RocketMQ:消息可靠性、顺序性与幂等处理的全面实践
apache·rocketmq
老虎06276 天前
JavaWeb(苍穹外卖)--学习笔记17(Apache Echarts)
笔记·学习·apache