Example: using Several Catch Exception Clauses
try {With Java SE 7 if the handling of each exception is identical, you can add as many exception types as you want, separated by a pipe character as shown in the following code:
// Do something
} catch(SAXExceptione) {
e.printStackTrace();
} catch(IOExceptione) {
e.printStackTrace();
} catch(ParserConfigurationExceptione) {
e.printStackTrace();
}
Example: Using Multicatch Exception
try {
// Do something
} catch(SAXException | IOException | ParserConfigurationException e) {
e.printStackTrace();
}
Nessun commento:
Posta un commento