问:如何在处理异常后恢复代码运行? 我现在使用 try and catch。
Try
{
Process url and render the text and save contents to text file.
}Catch(Exception ex)
}
一些 url 已损坏,那么如何跳过损坏的 url 并继续使用其他 url?
最佳答案
取决于您如何遍历 URL。例如:
for (URL url: urllist) {
try {
// Process **one** url
} catch (Exception ex) {
// handle the exception
}
}
这将处理列表中的所有 url,即使某些处理引发异常也是如此。
关于java - 处理异常后如何恢复代码运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5210720/