Reputation: 4941
I get a few exceptions when I run my code.
What I want to do is, I want to continue on FileNotFoundException
and NullPointerException
and break on any other exception.
How can I go about it? Thanks
Upvotes: 0
Views: 844
Reputation: 1
multiple catch block to caught exception arised in try block
<code>
try{<br/>
// Code that may exception arise.<br/>
}catch(<exception-class1> <parameter1>){<br/>
//User code<br/>
}catch(<exception-class2> <parameter2>){<br/>
//User code<br/>
}catch(<exception-class3> <parameter3>){<br/>
//User code<br/>
}
</code>
Source : Tutorial Data - Exception handling
Upvotes: 0
Reputation: 120308
You can do this as @daniel suggested, but I have some additional thoughts.
Upvotes: 0
Reputation: 28104
try {
stuff()
} catch( NullPointerException e ) {
// Do nothing... go on
} catch( FileNotFoundException e ) {
// Do nothing... go on
} catch( Exception e ) {
// Now.. handle it!
}
Upvotes: 5