What is correct about the following code snippet? (Choose all that apply.)
Files.move(Paths.get("sql.txt"), Paths.get("/data"), StandardCopyOption.ATOMIC_MOVE, LinkOption.NOFOLLOW_LINKS);
C, E.
The REPLACE_EXISTING flag was not provided, so if the target exists, it will throw an exception at runtime and A is incorrect.
Next, the NOFOLLOW_LINKS
option means that if the source is a symbolic link, the link itself and not the target will be copied at runtime, so B is also incorrect.
The option ATOMIC_MOVE means that any process monitoring the file system will not see an incomplete file during the move, so C is correct.
D is incorrect, since you could rename a file not to have an extension.
Note that in this example, if sql.
txt is a file, then the resulting /data would be a file, not a directory.
Likewise, if the source is a directory, the result would also be a directory.
E is correct, because moving always preserves the metadata even if the COPY_ATTRIBUTES flag is not set.