老是,我这写的URL出现这个情况?

来源:2-2 Java 中的 URL 的应用

小滕lo

2015-12-14 21:00

java.net.UnknownHostException: www.baidu.com

at java.net.AbstractPlainSocketImpl.connect(Unknown Source)

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.SocksSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at sun.net.NetworkClient.doConnect(Unknown Source)

at sun.net.www.http.HttpClient.openServer(Unknown Source)

at sun.net.www.http.HttpClient.openServer(Unknown Source)

at sun.net.www.http.HttpClient.<init>(Unknown Source)

at sun.net.www.http.HttpClient.New(Unknown Source)

at sun.net.www.http.HttpClient.New(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

at java.net.URL.openStream(Unknown Source)

at com.helloworld.HelloWorld.main(HelloWorld.java:33)


写回答 关注

2回答

  • owen欧阳
    2017-05-31 09:59:10

    我碰到了一样的问题,同样的代码在家中电脑上运行没问题,在公司电脑运行却一直报这个错误。

  • 小滕lo
    2015-12-14 21:01:11

    换了好几个网址都不行

    1995fl...

    没加http://吗?

    2016-02-10 10:05:28

    共 1 条回复 >

Java Socket应用---通信是这样练成的

分享的是 Java 中的网络编程,使用Socket实现网络聊天通信

125013 学习 · 590 问题

查看课程

相似问题