Question: The given program is being written using normal try and catch blocks and we need finally block to close the opened resources, you need

The given program is being written using normal try and catch blocks and we need finally block to close the opened resources, you need to Re-write the following code by using try-with- resources. FileInputStream in = null; FileOutputStream out = null; try{ in = new FileInputStream("file.txt"); out = new FileOutputStream("out.txt"); // Rest of the Code } catch (FileNotFoundException fnf) { } finally{\ try{ in.close(); if (out != null) out.close(); if(in != null) } catch (IOException ioe) { ... }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
