我有一个使用以下命令读取 HTML 页面的 swing 应用程序
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;
然后我的 swing 应用程序将返回一个字符串,它工作正常并且它读取我提供给它的任何 HTML 页面。但是,有时应用程序会给我以下错误类型的异常报告。我怎样才能增加超时时间?
最佳答案
this page 上有一个例子.
Jsoup.connect("http://example.com").timeout(3000)
关于java - SocketTimeoutException : Read timed out, 如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9002659/