Given the following code fragment: Which two codes fragment, when inserted independently
at line 12, move the report.txt file to the company directory, at the same level, replacing the
file if it already exists?
A.
Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.ATOMIC_MOVE);
B.
Files.move(p1, p2, StandardCopyOption.REPLACE_Existing,
LinkOption.NOFOLLOW_LINKS);
C.
Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING,
LinkOption.NOFOLLOW_LINKS);
D.
Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.copy_ATTRIBUTES, StandrardCopyOp)
E.
Files.move (p1, p2, StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.copy_ATTRIBUTES, LinkOption.NOF)
Only A
C (NOFOLLOW_LINKS) is for files.copy()
MOVE
h t t p s : / / docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#move(java.nio.file.Path,%20java.nio.file.Path,%20java.nio.file.CopyOption…)
The options parameter may include any of the following:
REPLACE_EXISTING
ATOMIC_MOVE
COPY
h t t p s : / / docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#copy(java.io.InputStream,%20java.nio.file.Path,%20java.nio.file.CopyOption…)
The options parameter may include any of the following:
REPLACE_EXISTING
ATOMIC_MOVE
NOFOLLOW_LINKS
Sorry, A and C
Files.move (p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
Files.move (p1, p2, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS);
public static Path move (
Path source,
Path target,
CopyOption… options) throws IOException
MOVE :
The options parameter (Interface CopyOption) may include any of the following
REPLACE_EXISTING, ATOMIC_MOVE
An implementation of this interface may support additional implementation specific options
Interface CopyOption
h t t p s : / / docs.oracle.com/javase/7/docs/api/java/nio/file/CopyOption.html
public interface CopyOption
An object that configures how to copy or move a file.
All Known Implementing Classes: LinkOption, StandardCopyOption
Enum StandardCopyOption: The StandardCopyOption enumeration type defines the standard options.
public enum StandardCopyOption extends Enum implements CopyOption
Enum LinkOption : Defines the options as to how symbolic links are handled.
public enum LinkOption extends Enum implements OpenOption, CopyOption