Question: Please write this in java Rewrite the following program so that it uses try-with-resources to eliminate the calls to closeC). Use only one try block.
Please write this in java



Rewrite the following program so that it uses try-with-resources to eliminate the calls to closeC). Use only one try block. import java.io. class NoTrywithResources public static void main(String arga) PileInputStream fin-null; FileOutputStream fout null ; // First make sure that both files have been specified if(args.length != 2) { System.out.println("Usage: NoTrywithResources Prom To") return; try( fin-new FileInputstream(args [o]) catch (IOBxception exc) System.out printin("IOException: program halted.") try f fout new FileOutputStream (args [1] ) ; catch (IOBxception exc) System.out printin("IOException: program halted.") try if (fin-null&& fout!null) int c = fn . read ( ); fout.write(c)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
