简体   繁体   English

在Java中将docx或doc文件转换为txt的最佳方法是什么?

[英]What is the best way to convert docx or doc file into txt in java?

I have tried to find a good way to convert but all off them not working with all the external jars that I'm required to add. 我试图找到一种转换的好方法,但是所有这些都不能与我需要添加的所有外部jar一起使用。 Is there any one who knows easy / possible solution? 有谁知道简单/可行的解决方案?

the best way is not. 最好的方法不是。 a doc(x) file can contain other than plain-text content, while a txt file can't. doc(x)文件可以包含纯文本内容,而txt文件则不能。

what you could do, if you only need the text, is to use apache poi to read all the text from your doc(x) file, and a basic FileWriter to write it to a txt file. 如果只需要文本,您可以做的是使用apache poi读取doc(x)文件中的所有文本,并使用基本的FileWriter将其写入txt文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM