51CTO技术论坛 » Java » 使用TextMiniing和Apache POI获得Word文件内容,无须MS-Office ActiveX        上一帖     下一帖    查看完整版本

页: [1]

感冒不好玩2006-8-28 18:32
使用TextMiniing和Apache POI获得Word文件内容,无须MS-Office ActiveX

/** Created on 2005/07/18* 使用tm-extractors-0.4.jar*/package com.nova.colimas.common.doc;import java.io.FileInputStream;import java.io.FileOutputStream;import org.textmining.text.extraction.WordExtractor;/*** Deal with ms-word 2000/xp files.* @author tyrone**/public class WordProcess extends DocProcess {public static String run(String filename){WordExtractor extractor=null;String text=null;try{FileInputStream in = new FileInputStream (filename);extractor = new WordExtractor();text=extractor.extractText(in);}catch(Exception ex){//logreturn null;}return text;}public static void main(String[] args){try{FileOutputStream out=new FileOutputStream("result.txt");out.write(WordProcess.run(args[0]).getBytes());out.flush();out.close();}catch(Exception ex){System.out.println(ex.toString());}}}

关键词: office       apache       word       文件       MS       

相关文章:
CCNA REAL-EXAMS 640-861 V26.0
新代NAS-商业连接性及灾备方案的高级文件系统
超小型局域网FTP支持大文件下载
社区及其启动 (转自MSDN)
用来分割文件的东西-飞雪万能分割机

查看完整版本: 使用TextMiniing和Apache POI获得Word文件内容,无须MS-Office ActiveX


Powered by 51CTO.COM