对WordExtractor的引用含糊不清

时间:2014-12-29 14:38:16

标签: java apache file

我试图从.doc文件中读取。这是我的代码:

import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;

public class ReadDocFile {

public static void main(String[] args) {
    File file = null;
    WordExtractor extract = null;
    try {

        file = new File("c:\\New.doc");
        FileInputStream fis = new FileInputStream(file.getAbsolutePath());
        HWPFDocument document = new HWPFDocument(fis);
        extract = new WordExtractor(document);
        String[] fileData = extract.getParagraphText();
        for (int i = 0; i < fileData.length; i++) {
            if (fileData[i] != null) {
                System.out.println(fileData[i]);
            }
        }
    } catch (Exception exep) {
    }
}
}

它在以下行显示红色错误:

extract = new WordExtractor(document);

错误在说, 对词提取器的引用是模糊的 WordExtractor中的构造函数WordExtractor(DirectoryNode)和WordExtractor中的构造函数WordExtractor(HWPFDocument)匹配

帮助我。

1 个答案:

答案 0 :(得分:0)

我有同样的问题,我从

添加了3.0版本

http://www.findjar.com/jar/poi/poi/3.0-FINAL/poi-3.0-FINAL.jar.html