1z0-809 Exam QuestionsBrowse all questions from this exam

1z0-809 Exam - Question 220


Given the code fragment:

Path source = Paths.get ("/data/december/log.txt");

Path destination = Paths.get("/data");

Files.copy (source, destination);

/data/december/log.txt is accessible and contains:

and assuming that the file

10-Dec-2014 Executed successfully

What is the result?

log.txt is created in the /data directory and the content of the /data/december/log.txt file is copied to it.

Show Answer
Correct Answer: BC

When the Files.copy method is used without specifying an option to replace the existing file, it throws a FileAlreadyExistsException if the target file already exists. In this case, since the destination is a directory (/data) and there is no additional option provided to handle overwriting, the program will throw a FileAlreadyExistsException at runtime.

Discussion

4 comments
Sign in to comment
Ritesh_Option: C
Oct 13, 2019

Answer is C

WilsonKKerllOption: C
Mar 22, 2022

Answer is C.

iSnoverOption: C
Feb 7, 2024

Answer is C.

DarGrinOption: C
Jun 8, 2024

java.nio.file.FileAlreadyExistsException: data