我已经编写了一个程序来读取我的Microsoft Word文档文件的内容。我的要求是获取word.doc的文档图,我开始阅读我的代码所在的doc文件。
public static void readParagraphs(HWPFDocument doc) throws Exception
{
WordExtractor we = new WordExtractor(doc);
/**Get the total number of paragraphs**/
String[] paragraphs = we.getParagraphText();
System.out.println("Total Paragraphs: "+paragraphs.length);
for (int i = 0; i < paragraphs.length; i++)
{
System.out.println("Length of paragraph "+(i +1)+": "+ paragraphs[i].length());
System.out.println(paragraphs[i].toString());
}
}
but am getting Exception in thread "main" java.lang.NoSuchFieldError: filesystem
at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:218)
at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:158)
at com.honeywell.corept.srd.ReadDocFileFromJava.readMyDocument(ReadDocFileFromJava.java:25)
at com.honeywell.corept.srd.ReadDocFileFromJava.main(ReadDocFileFromJava.java:18)
此异常无法解决此问题。请帮忙。
答案 0 :(得分:7)
请检查您的课程路径上是否有两份POI JAR副本。
如果是,请保留单份副本。