Given the code fragment:private static void copyContents (File source, File target) { try {inputStream fis = new FileInp

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899559
Joined: Mon Aug 02, 2021 8:13 am

Given the code fragment:private static void copyContents (File source, File target) { try {inputStream fis = new FileInp

Post by answerhappygod »

Given the code fragment:private static void copyContents (File source, File target) { try {inputStream fis = new FileInputStream(source); outputStream fos = new FileOutputStream (target); byte [] buf = new byte [8192]; int i; while ((i = fis.read(buf)) != -1) { fos.write (buf, 0, i);//insert code fragment here. Line **System.out.println ("Successfully copied");Which code fragments, when inserted independently at line **, enable the code to compile?

A. } catch (IOException | NoSuchFileException e) { System.out.println(e); }
B. } catch (IOException | IndexOutOfBoundException e) { System.out.println(e); }
C. } catch (Exception | IOException | FileNotFoundException e ) { System.out.println(e); }
D. } catch (NoSuchFileException e ) { System.out.println(e); } E. } catch (InvalidPathException | IOException e) { System.out.println(e); }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!

This question has been solved and has 1 reply.

You must be registered to view answers and replies in this topic. Registration is free.


Register Login
 
Post Reply