Page 1 of 1

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

Posted: Wed Jun 07, 2023 6:11 am
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); }