文件内容提取:Apache Tika 2.9.2

embedded/2024/10/10 23:58:28/

提取各种文件的文本内容,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.ppmy.cn/embedded/125263.html

相关文章

开发指南067-单元测试

平台中单元测试使用两个工具&#xff1a; 1、接口类&#xff1a;使用swagger。 swagger前面介绍已经很多了&#xff0c;不再累述。注意下token的设置即可&#xff0c;否则会报未登录&#xff0c;无法调用该接口。当然也可以修改代码&#xff0c;屏蔽校验。但是屏蔽校验无法获取…

Linux下send函数和recv函数

1. 基本介绍 send 函数 send 函数用于向一个已连接的套接字发送数据。它的典型使用场景是在TCP通信中&#xff0c;客户端和服务器之间交换数据。 函数声明&#xff1a; ssize_t send(int sockfd, const void *buf, size_t len, int flags); 参数解释&#xff1a; sockfd&a…

LabVIEW混合控制器质量检测

随着工业自动化水平的提高&#xff0c;对控制器的精度、稳定性、可靠性要求也在不断上升。特别是在工程机械、自动化生产、风力发电等领域&#xff0c;传统的质量检测方法已无法满足现代工业的高要求。因此&#xff0c;开发一套自动化、精确、可扩展的混合控制器质量检测平台成…

vmware+centos安装配置

镜像下载 阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区 centos-Download

SpringBoot整合异步任务执行

同步任务&#xff1a; 同步任务是在单线程中按顺序执行&#xff0c;每次只有一个任务在执行&#xff0c;不会引发线程安全和数据一致性等 并发问题 同步任务需要等待任务执行完成后才能执行下一个任务&#xff0c;无法同时处理多个任务&#xff0c;响应慢&#xff0c;影响…

Springboot 文件上传

文件上传&#xff0c;是指将本地图片、视频、音频等文件上传到服务器&#xff0c;供其他用户浏览或下载的过程。 文件上传前端需要完成的准备&#xff1a; 需要提交一个form表单&#xff0c;表单必须包含以下三点&#xff08;上传文件页面三要素&#xff09; …

[MAUI]数据绑定和MVVM:MVVM的属性验证

一、MVVM的属性验证案例 Toolkit.Mvvm框架中的ObservableValidator类,提供了属性验证功能,可以使用我们熟悉的验证特性对属性的值进行验证,并将错误属性提取和反馈给UI层。以下案例实现对UI层的姓名和年龄两个输入框,进行表单提交验证。实现效果如下所示 View<ContentP…

JavaSE——集合1:Collection接口(Iterator和增强for遍历集合)

目录 一、集合框架体系(重要) 二、集合引入 (一)集合的理解与好处 三、Collection接口 (一)Collection接口实现类的特点 (二)Collection接口常用方法 (三)Collection接口遍历元素的方式(Iterator和增强for) 1.使用Iterator(迭代器) 1.1Iterator(迭代器)介绍 1.2Itera…