| Author |
static method and exception
|
arjun rampal
Ranch Hand
Joined: Jul 08, 2005
Posts: 125
|
|
I have file which is reading from file and deleting it. delete is done by static method. now i need to do like this if file is empty it should throw exception and delte the file. so i added else like this else{ throw new empty("Empty"); } but it is only thorowing exception not deleting file.as that static code is unreachable after throwing exception. any idea
|
 |
John Kelty
Ranch Hand
Joined: Aug 08, 2006
Posts: 33
|
|
If I understand right, you want to delete the file whether or not you throw an exception. Try placing the file delete logic in a finally {} block. --John
|
 |
Greg Charles
Bartender
Joined: Oct 01, 2001
Posts: 2539
|
|
|
Or, find out if the file is empty and save that into a boolean variable. Then delete the file, then take any action based on the boolean that you think is appopriate.
|
 |
 |
|
|
subject: static method and exception
|
|
|