qq_40838030
从小我就黑
2018-09-10 04:25
采纳率: 84.1%
浏览 2.2k
已采纳

java.net.UnknownHostException: src="https运行报错

用InputStream解析url 但是运行时报错
URL url = new URL("http://"+matcher2.group());
URLConnection con = url.openConnection();
con.setConnectTimeout(120*1000);
InputStream is = con.getInputStream();
下面是报错
java.net.UnknownHostException: src="https
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • oyljerry
    oyljerry 2018-09-10 05:12
    已采纳

    你拼接出来的url应该有问题。地址不对

     RL url = new URL("http://"+matcher2.group());
    
    点赞 评论
  • zhangpan_soft
    zhangpan_soft 2018-09-10 05:40

    这个没什么原因,就是地址错了,你看报错是报的src="https",这是什么鬼?你那里有https?错误要找准,

    点赞 评论
  • xcgh
    xcgh 2018-09-10 05:40

    你是http连接https吧,需要使用客户端完全信任服务端,否则客户端需要服务端给证书

    点赞 评论

相关推荐