Integer count = 0;
Integer maxTries = 3;
while(true) {
    try {
        // Some Code
        // break out of loop, or return, on success
    } catch (Exception e) {
        // handle exception
        if (++count == maxTries) throw e;
    }
}