While adding a try/catch block in Eclipse, it gave me the option of "Surround with try/multi-catch" or "Surround with try/catch."
This is the try/multi-catch:
try { save.load(new FileInputStream(file.getAbsolutePath())); } catch (FileNotFoundException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } This is the single try/catch:
try { save.load(new FileInputStream(file.getAbsolutePath())); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } What are the benefits/repercussions of using one or the other? If I'm correct, the first example will execute the catch block when EITHER of the exceptions are thrown and produce the SAME CATCH, while the second example will throw a catch based on the exception while enabling separate catch blocks.
Is there anything else I should know about this? I've never used them before and don't know if they are worth using.
FileNotFoundExceptionis anIOException.