ITeye博客

使用POI抽取Word内容

longforfreedom · 2009-12-03 20:33 · JAVA · Markdown

使用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();
	}

评论(1)

  1. #1 楼 · itfirefly · 2011-11-04 16:01

    你这么写不怕给骂人

评论功能维护中,当前仅展示历史评论。