try { somethingDangerous(); } catch ( IOException e ) { System.out.println( "oh oh" ); throw new BadDataException(); } finally { file.close(); // always executed }