InputStream在org.apache.pdfbox.text.PDFTextStripper返回NullPointer:java.lang.NullPointerException。<clinit>(PDFTextStripper.java:1825)

时间:2017-10-14 03:42:14

标签: java pdfbox

我试图使用pdfbox 2.0.7源版本和lucene 6.6.0索引pdf文件。 我得到以下错误。

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.pdfbox.examples.lucene.LucenePDFDocument.addContent(LucenePDFDocument.java:361)
    at org.apache.pdfbox.examples.lucene.LucenePDFDocument.convertDocument(LucenePDFDocument.java:254)
    at org.apache.pdfbox.examples.lucene.LucenePDFDocument.getDocument(LucenePDFDocument.java:326)
    at javaapplication18.JavaApplication18.indexDocs(JavaApplication18.java:112)
    at javaapplication18.JavaApplication18.indexDocs(JavaApplication18.java:90)
    at javaapplication18.JavaApplication18.main(JavaApplication18.java:67)
Caused by: java.lang.NullPointerException
    at org.apache.pdfbox.text.PDFTextStripper.<clinit>(PDFTextStripper.java:1825)
    ... 6 more

并打开PDFTextStripper.java并找到此

static
    {
        String path = "org/apache/pdfbox/resources/text/BidiMirroring.txt";
        InputStream input = PDFTextStripper.class.getClassLoader().getResourceAsStream(path);
        try
        {
            parseBidiFile(input);
        }
        catch (IOException e)
        {
            LOG.warn("Could not parse BidiMirroring.txt, mirroring char map will be empty: "
                    + e.getMessage());
        }
        finally
        {
            try
            {
                input.close(); // here is PDFTextStripper.java:1825
            }
            catch (IOException e)
            {
                LOG.error("Could not close BidiMirroring.txt ", e);
            }
        }
    }

PDFTextStripper.java:1825指向input.close();

我需要帮助。我应该怎么做?

0 个答案:

没有答案