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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!