If a method can throw multiple exceptions, how to declare it?
public writeThisToFile(String line) throws FileNotFoundException, AppSpecificServiceException, SecurityException{
/* some thing */
}
See Also
- § 8.4.6 Method Throws
public void yourMethod() throws anException, anotherException {
//stuff here
}
Using the throws
clause:
public void myMethod()
throws Exception1, Exception2
{
...
}