Which two statements are true about the walkFileTree method of the files class?

Which two statements are true about the walkFileTree method of the files class?

Which two statements are true about the walkFileTree method of the files class?

A.
The file tree traversal is breadth-first with the given FileVisitor invoked for each file
encountered.

B.
If the file is a directory, and if that directory could not be opened, the postVisitFileFailed method
is invoked with the I/O exception.

C.
The maxDepth parameter’s value is the maximum number of directories to visit.

D.
By default, symbolic links are not automatically followed by the method.

Explanation:
C: The method walkFileTree(Path start, Set<FileVisitOption> options, int maxDepth,
FileVisitor<? super Path> visitor)
walks a file tree.
The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0
means that only the starting file is visited, unless denied by the security manager. A value of
MAX_VALUE may be used to indicate that all levels should be visited. The visitFile method is
invoked for all files, including directories, encountered at maxDepth, unless the basic file attributes
cannot be read, in which case the visitFileFailed method is invoked.
D:You need to decide whether you want symbolic links to be followed. If you are deleting files, for
example, following symbolic links might not be advisable. If you are copying a file tree, you might
want to allow it. By default, walkFileTree does not follow symbolic links.
Reference: The Java Tutorials, Walking the File Tree
Reference: walkFileTree



Leave a Reply 0

Your email address will not be published. Required fields are marked *