日期:2014-05-20 浏览次数:20872 次
package se.analyzer.parser.impl; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import org.apache.poi.hwpf.extractor.WordExtractor; import se.analyzer.parser.Parsable; import se.analyzer.parser.Parser; public class WordParser extends Parser implements Parsable { @Override public String getContext(File arg) { FileInputStream in = null; StringBuffer context = new StringBuffer(); try { if (arg.exists()) { in = new FileInputStream(arg); WordExtractor wordExtractor = new WordExtractor(in); context.append(wordExtractor.getText()); } else { context.append("file not exists"); } } catch (FileNotFoundException e) { context.append("file not exists"); e.printStackTrace(); } catch (IOException e) { context.append("file not exists"); e.printStackTrace(); } finally { } return context.toString(); } }
------解决方案--------------------
jacob
开源包
java本身不支持