使用Java将Microsoft Word文档读入纯文本(DOC,DOCX) [英] Read Microsoft Word Documents into Plain Text (DOC, DOCX) in Java
本文介绍了使用Java将Microsoft Word文档读入纯文本(DOC,DOCX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找Java中的东西来阅读Word文档来处理他们的文本..我需要的只是文本,没什么特别的。我知道Apache POI,但它现在不包括对DOCX的支持,那里有什么东西?
I'm looking for something in Java to read in Word documents to process their text.. all I need is there text, nothing fancy. I know about Apache POI, however it doesn't include support for DOCX right now, anything out there?
推荐答案
如果你不喜欢不需要格式化信息,图像和所有其他花哨的东西,那么工作就容易多了。只需要5到10行代码即可。
If you don't require formatting information, images and all other fancy stuff, then the job is lot easier. Just some 5 to 10 lines of code will do.
- 将DOCX视为zip文件。它包含一堆包含'document.xml'的文件。使用ZipInputStream并单独提取该文件。 (您可以使用自己喜欢的zip工具并打开docx并自己查看!)
- 使用SAX解析器并读取节点主体/ p / r / t之间的内容 - 瞧,你有文字!
仅当您需要纯文字时才适用。
这篇关于使用Java将Microsoft Word文档读入纯文本(DOC,DOCX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文