Java – sockettimeoutexception: read timeout. How to solve it?
•
Java
I have a swing application that reads HTML pages using the following command
String urlzip = null;
try {
Document doc = Jsoup.connect(url).get();
Elements links = doc.select("a[href]");
for (Element link : links) {
if (link.attr("abs:href").contains("BcfiHtm.zip")) {
urlzip = link.attr("abs:href").toString();
}
}
} catch (IOException e) {
textAreaStatus.append("Failed to get new file from internet:"+e.getMessage()+"\n");
e.printStackTrace();
}
return urlzip;
Then my swing application will return a string, it works normally, and it reads any HTML page I give it However, sometimes the application gives me the following error type exception reports How can I increase my time?
Solution
There is an example on this page
Jsoup.connect("http://example.com").timeout(3000)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
