This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
i have a condition say i am doing i/o operation and i did not get the file at the path specified and the whole code is in a try catch block.when i execute an exception is raised then the catch block gets executed and the process terminates.
now what my question is i do not want the process to be terminated i want it again to execute the method which threw that exception.
You have to check that condition yourself using methods in the File API before performing any operation over file. You can use exists() method to achieve this. If you get a negative result then you can code it to repeat the same sequence how many times you need.
There is nothing you can do in case of Try - Catch.Once exception is caught then the program is tend to terminate. [ January 10, 2008: Message edited by: Balasubramanian Chandrasekaran ]
You could put your try block inside a loop, like thisSomething I just knocked up in a minute, risk of its returning a zero-length List if anything goes wrong, or a zero-length String as the last element, but it gives an opportunity of repeating the reading if there is an Exception.