3
java.lang.NullPointerException
java.net.SocketTimeoutException: connect timed out
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    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 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 org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:404)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:391)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:157)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:146)

== 我在:

try
{
..
Document doc = Jsoup.connect(recevurl).get();
..

}
catch (IOException| NullPointerException ee)
{
ee.printStackTrace();
}

我不知道如何摆脱这个异常?还有什么办法可以解决这个问题吗?我在想 IOException 会处理这个!

4

1 回答 1

5

尝试Document doc = Jsoup.connect(recevurl).timeout(3000).get();

于 2012-08-30T14:45:38.163 回答