我已经为URLconnection以及Parser类实现了try catch块,如下所示。如何在一个try/catch块中捕获异常和SocketTimeOut异常
try {
Url uri = new Url(urlString);
Parser parse = new Parser(uri);
} catch (Exception e)
{
//ignore some other exceptions
}
catch (SocketTimeOutException e)
{
//I want to catch this exception and do some thing or restart
//if it's a timeout issue.
//I am using a proxy for the network connection at JVM setting
//using setProperty
}
所以,我的问题是如何根据该SocketTimeOutException情况采取相应的行动,并为其他异常忽略。
感谢,
只能将一个赶上(例外五){...}所有其他异常 –