当前位置: 首页 > article >正文

文件内容提取:Apache Tika 2.9.2

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

Apache Tika 2.9.2 、 jdk8

基础 pom.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

<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

@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));
    }
}

http://www.kler.cn/news/339470.html

相关文章:

  • InnoDB 磁盘结构 - RedoLog
  • 【数据分享】全国地级市2000-2022年公路里程数据(Shp/Excel格式)
  • 2024年下半年软考准考证什么时候打印?
  • sklearn机器学习实战——随机森林回归与特征重要性分析全过程(附完整代码和结果图)
  • 时间卷积网络(TCN)原理+代码详解
  • 【React】setState 是怎么记住上一个状态值的?
  • 蒙特卡罗方法 - 重要采样篇
  • 《Linux从小白到高手》理论篇:深入理解Linux的计划任务/定时任务
  • Axure PR 9 开关切换 设计交互
  • JPA 概述及描述对象和表之间的映射关系注解
  • 线程安全反思录(上):ThreadLocal到底安全不?
  • 优化Kafka存储:热冷数据分层策略
  • Linux No space left on device分析和解决
  • 软件测试之压力测试
  • CentOS7 虚拟机操作系统安装及相关配置教程
  • [Algorithm][贪心][整数替换][俄罗斯套娃信封问题]详细讲解
  • PyQt入门指南七 自定义信号与槽的使用
  • “降维模糊C均值(PCA-FCM)”创新算法的聚类与可视化
  • opencv级联分类器实现人脸识别
  • 从其他视角认识梯度反向传播(BP):基于自动微分的全波形反演 (ADFWI)