问答详情
源自:2-2 Java 中的 URL 的应用

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

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)


提问者:小滕lo 2015-12-14 21:00

个回答

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

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

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

    换了好几个网址都不行