我已经编写了一个程序来读取我的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)


此异常无法解决此问题。请帮忙。

最佳答案

请检查您的类路径上是否有POI JAR的两个副本。

如果是,请保留一份副本。

10-04 13:34