| Author |
how can i resume to the next instruction when my previous instruction raised excption
|
siddhu Math
Ranch Hand
Joined: Aug 10, 2006
Posts: 46
|
|
hi 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. ---------------
|
 |
Balasubramanian Chandrasekaran
Ranch Hand
Joined: Nov 28, 2007
Posts: 215
|
|
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 ]
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
|
Do you have control over the client which executes the I/O method? If so, the client can handle the exception and do something like prompt the user to reinput the filename and resubmit the request.
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
|
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.
|
 |
 |
|
|
subject: how can i resume to the next instruction when my previous instruction raised excption
|
|
|