word转txt
import org.apache.poi.hwpf.extractor.WordExtractor;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
public class Doc2Text {
Doc2Text() throws IOException {
var fojingPath = "/home/weiyinfu/Desktop/佛经";
var targetPath = "/home/weiyinfu/Desktop/fojing";
if (!Files.exists(Paths.get(targetPath))) {
Files.createDirectory(Paths.get(targetPath));
}
Files.list(Paths.get(fojingPath)).forEach(docPath -> {
try {
InputStream cin = Files.newInputStream(docPath);
WordExtractor extractor = new WordExtractor(cin);
cin.close();
String content = extractor.getText();
String filename = docPath.getFileName() + ".txt";
var cout = Files.newBufferedWriter(Paths.get(targetPath).resolve(filename), StandardOpenOption.CREATE);
cout.write(content);
cout.close();
} catch (IOException e) {
e.printStackTrace();
}
});
}
public static void main(String[] args) throws IOException {
new Doc2Text();
}
}
需要POI
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.0</version>
</dependency>
word转txt的更多相关文章
- word和.txt文件转html 及pdf文件, 使用poi jsoup itext心得
word和.txt文件转html 及pdf文件, 使用poi jsoup itext心得本人第一次写博客,有上面不足的或者需要改正的希望大家指出来,一起学习交流讨论.由于在项目中遇到了这一个问题,在 ...
- iOS 应用中加载文档pdf/word/txt
一.加载PDF文档:应用内打开文档.手机中其他应用打开文档 Demo 首先拖入一个文档pdf.word.txt,打开不同的文档知识 文件名字.类型修改即可 #import "ReadView ...
- ASP.NET MVC在线预览Excel、Word、TXT、PDF文件
代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...
- WPF: 读取XPS文件或将word、txt文件转化为XPS文件
读取XPS格式文件或将doc,txt文件转化为XPS文件,效果图如下: 1.XAML页面代码: <Window x:Class="WpfWord.MainWindow" xm ...
- WFP: 读取XPS文件或将word、txt文件转化为XPS文件
读取XPS格式文件或将doc,txt文件转化为XPS文件,效果图如下: 1.XAML页面代码: <Window x:Class="WpfWord.MainWindow" ...
- 2、Python djang 框架下的word Excel TXT Image 等文件的下载
2.python实现文件下载 (1)方法一.直接用a标签的href+数据库中文件地址,即可下载.缺点:word excel是直接弹框下载,对于image txt 等文件的下载方式是直接在新页面打开. ...
- python 将word另存为txt
import os import os.path from win32com import client as wc c=[] rootdir=["d:/77"] #以该路径为 ...
- Java实现Word/Pdf/TXT转html
引言: 最近公司在做一个教育培训学习及在线考试的项目,本人主要从事网络课程模块,主要做课程分类,课程,课件的创建及在线学习和统计的功能,因为课件涉及到多种类型,像视频,音频,图文,外部链接及文档类型. ...
- js 读取word和txt(react版) + 正则分割段落
show the code 前提:需要mammoth包~ import React, { useState, useReducer } from 'react'; import { Button, A ...
- MarkDown语法记录,还在用word,txt编写项目文档吗?
开始之前 是不是在github上看项目的时候第一眼就要看项目介绍? 是不是经常在某些项目的代码里面看到一个README.MD文档 却不知道怎么写? 你是不是不知道,反正我是的. 作为一个程序员,可能写 ...
随机推荐
- [b0008] Windows 7 下 hadoop 2.6.4 eclipse 本地开发调试配置
目的: 基于上篇的方法介绍,开发很不方便 .[0007] windows 下 eclipse 开发 hdfs程序样例 装上插件,方便后续直接在windows下的IDE开发调试. 环境: Linux ...
- BayaiM__ oracle函数_01
BayaiM__ oracle函数_01 Oracle函数--------------------------------------------------------------------- ...
- Linux根目录下各目录含义
/boot:系统启动的相关文件,比如内核,grub /etc:配置文件 /dev:设备文件 /root:root用户的家目录 /home:用户家目录 /lib:库文件 /bin:用户的命令文件 /sb ...
- C# Session 操作类
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- [Go] gocron源码阅读-go语言web框架Macaron
gocron源码中使用的是马卡龙框架,下面这个就是安装这个框架,和一般的MVC框架很像go get gopkg.in/macaron.v1git clone https://github.com/go ...
- Windows文件夹共享和Unity的PersisterdataPath
在共享机上存放unity开发的pc版本游戏,在其它机器双击就可以运行,但会遇到问题,比如: 游戏是需要下载资源的,默认情况下unity下载的资源是存放在persisterdataPath目录的,对于w ...
- nginx默认配置文件解释
nginx默认配置文件 nginx.conf 介绍: 全局配置 user nginx; 设置nginx服务的系统使用用户 worker_processes 1; 工作进程数(建议和CPU核心数保持 ...
- Rust多线程中的消息传递机制
代码说话. use std::thread; use std::sync::mpsc; use std::time::Duration; fn main() { let (tx, rx) = mpsc ...
- 201871010113-刘兴瑞《面向对象程序设计(java)》第二周学习总结
项目 内容 这个作业属于哪个课程 <任课教师博客主页链接> https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 <作业链接地址> ...
- 2019.6.11_MySQL进阶二:主键与外键
通过图形界面(UI)创建外键 打开设计表,在对应的栏位填写相应的内容.其中FK_deptno是限制名 # 先给主表建立主键 ALTER TABLE dept ADD PRIMARY KEY(dep ...