FileUtils.copyURLToFile(url,destination);

时间:2018-10-26 14:05:56

标签: java selenium testng

当我尝试下载PDF文件时,我使用了以下代码

final String fileURL = "url";
final String filepath ="C:\\FileDownload\\";
final String FILENAME = "data.pdf";

File file = new File(filepath + FILENAME);
URL url = new URL(fileURL);

try {
     FileUtils.copyURLToFile(url, file);
} catch (Exception x) 
{ x.printStackTrace(); }

得到的错误是,

javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target

可以帮助您解决此问题。

0 个答案:

没有答案