Re: Do you need finally when your method throws Exception..



On Fri, 30 Sep 2005 04:50:13 +0800, zero wrote
(in article <Xns96E0E84BBAEEzerothishi@xxxxxxxxxxxxxx>):

> Roedy Green <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx> wrote in
> news:sikoj11ghakm7kufces5c369u8iip78po8@xxxxxxx:
>
>> On Thu, 29 Sep 2005 18:29:55 GMT, zero <zero@xxxxxxx> wrote or quoted
>>>
>>
>>> if(resource == null)
>>> resource.close();
>> you meant to say
>>
>> if ( resource != null )
>> {
>> resource.close();
>> }
>
> oops, of course. Thanks for the correction :-)

actually it is going to be more like:

if ( resource != null ){
try{
resource.close();
}
catch(Exception e)
{
System.out.println("serious error , failed to close resource XYZ");
e.printStackTrace();
}
finally
{
// this is supposed to be empty
}

.



Relevant Pages