PageRank on undirected and weighted graph
java 删除文件夹

Java 读取 doc docx pdf rtf txt html 文件文本内容

Jimmy posted @ 2012年3月07日 00:25 in Java Programming , 5122 阅读

最近需要解析用户上传文档的文本内容,自己没有搜到很好的资料,在http://scturtle.is-programmer.com/的介绍下,找到了一些参考资料,于是很快的完成了基本文件格式的解析。下面把资料的链接跟代码地址附上

1.MS doc/docx/Excel/Powerpoint/...

解析微软的office文件有Apache的POI类库支持,只是doc/docx的工作还在完善之中,所以解析出来的格式不是很精确,比如图片部分不能完全去除掉会在解析得到的文本中留下部分乱码。

REF: http://poi.apache.org/

2.pdf

解析pdf文件有Apache pdfBox类库的支持,解析效果还不错。

REF:http://pdfbox.apache.org/

3. html

解析html有很强大的工具htmlParser, 无需保存网页文件,只需给一个网页链接,就可以得到html文件中的文本内容,而且可以自动过滤很多无用标签,很是强大。

REF: http://htmlparser.sourceforge.net/

REF: http://perfectlife.iteye.com/blog/366084

4 rtf

解析rtf有javax类库的支持,只需import javax.swing.text.rtf.RTFEditorKit;就能解决问题

5. txt

这个就无需解析了,直接读取文件的文本内容就行了。

其他的参考资料(未找到原文,所以文中提供的dll链接库无法下载,可以直接下载github上的代码)

REF: http://blog.sina.com.cn/s/blog_622bd1660100rk1r.html

REF: http://apps.hi.baidu.com/share/detail/16966435

代码在gitHub的下载地址: https://github.com/jia1546/content-extraction

Avatar_small
net worth 说:
2021年7月21日 01:14

Are you a celebrity? If you are, you will find your name and information on idol net worth - the database which is open for everyone.

Avatar_small
civaget 说:
2023年12月31日 01:46

러시아마사지 is the ultimate pampering experience.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter