使用POI3.5抽取Word内容只需要一句
/**
* 使用<a href="http://poi.apache.org/">POI</a>抽取MS office 2003 word格式的文件内容
* @param file
* MS Word2003 格式的{@link File}实例
* @return 文件内容的{@link String}
* @throws IOException
* @throws FileNotFoundException
*/
public String getContents(File file) throws FileNotFoundException,
IOException {
WordExtractor wordExtractor = new WordExtractor(new FileInputStream(
file));
return wordExtractor.getTextFromPieces();
}
相关资源:POI生成word文档