使用apache PDFBox运行以下代码时出现java.net.ConnectException

时间:2019-06-03 10:45:23

标签: java selenium

运行以下代码时,我正在获取java.net.ConnectException。谁能帮我吗?

package com.quantum.auto.common;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;


public class PDFReader {

    public void readPDFTest() throws IOException{
        URL url = new URL("https://www.betterteam.com/downloads/employee-information-form-download-20170810.pdf");
        //URLConnection urlcon = url.openConnection();
        InputStream is = url.openStream();
        BufferedInputStream fileParse = new BufferedInputStream(is);
        PDDocument document = null;

        document = PDDocument.load(fileParse);
        new PDFTextStripper().getText(document);
        String pdfContent = new PDFTextStripper().getText(document);
        System.out.println(pdfContent);

    }   
}

0 个答案:

没有答案