For the copy()
method shown here, assume that the source exists as regular file and that the target does not. What is the result of the following code?
Path path1 = Paths.get("./data.txt").normalize(); // k1 Path path2 = Paths.get("java.png"); Files.copy(path1,path2,StandardCopyOption.COPY_ATTRIBUTES); //k2 System.out.println(Files.isSameFile(path1, path2)); //k3
A.
The code compiles and runs without issue, so C, D, E, and F are incorrect.
Even though the file is copied with attributes preserved, the file is considered a separate file, so the output is false and A is correct and B is incorrect.
Remember, isSameFile()
returns true only if the files pointed to in the file system are the same, without regard to the file contents.