我写了一个多线程下载测试程序 照着教程做的 但运行提示错误
这个语句
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();提示错误 sun.net.www.protocol.http.HttpURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection
其中rul 为 URL url = new URL(path);
path 为 String path = http://localhost:8080/MyWebTest/download.ppt;
请问该如何解决?我查找了一下 有说是JDK的版本问题?
升级JDK,或者下载sun.net的包
在没有对使用的SSL实现类进行配置的情况下,在程序中如果正常使用Java.net.URL的不带 URLStreamHandler 参数的构造方法new 一个URL对象的话,url.openConnection()默认是返回sun.net.www.protocol.http.HttpURLConnection 类型对象。所以我们带上一个URLStreamHandler
参数。
URL url = new URL(null,url,new Handler());