【发布时间】:2019-01-21 07:05:34
【问题描述】:
我正在尝试从这些网址下载
"https://www.treasury.gov/ofac/downloads/sdn.xml" 但它是说
"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"
我尝试了以下两个,但它不起作用
1.System.setProperty("com.sun.security.enableAIAcaIssuers","true");
2.将我的java版本从1.7更新到1.8.0_121
download("https://www.treasury.gov/ofac/downloads/sdn.xml","D:\\AML_Files\\Download_Check\\sdnList.xml");
public static void download(String url, String fileName) throws Exception {
//System.setProperty("com.sun.security.enableAIAcaIssuers","true");
try (InputStream in = URI.create(url).toURL().openStream()) {
Files.copy(in, Paths.get(fileName));
}
}
我想在我的系统中下载 xml 文件,然后将该 xml 文件数据插入到数据库表中
【问题讨论】:
-
那么到底是什么问题呢?你有错误吗?结果错误?
-
我可以使用您的代码下载文件。 “下载(网址,”sdnList.xml“);”。所以我想这与JRE无关。我的 Java 版本是“1.8.0_144”
标签: java