3
Reply

Try Catch Finally

David

David

Jul 21 2006 1:51 PM
2.4k
Hi.

I was wondering if anybody could explain to me the purpose of the Finally block in exception handling. For example, what is the difference between these two pieces of code.

Example 1:

try
{
// open a file
}
catch (IOException ioe)
{
// log the error or something
}
finally
{
// do more stuff
}

Example 2:

try
{ // open a file
}
catch (IOException ioe)
{
// log the error or something
}
// do more stuff

Thanks,

Dave

Answers (3)