你需要将你
try-catch的
while循环包含在这样的循环中:-
int count = 0;int maxTries = 3;while(true) { try { // Some Code // break out of loop, or return, on success } catch (SomeException e) { // handle exception if (++count == maxTries) throw e; }}我已采取
count并
maxTries避免陷入无限循环,以防你的中不断发生异常
try block。



