我已經爲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情況採取相應的行動,併爲其他異常忽略。
感謝,
只能將一個趕上(例外五){...}所有其他異常 –