nerdexam
Oracle

1Z0-805 · Question #35

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

The correct answer is 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. 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…

Java I/O Fundamentals

Question

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

Options

  • AThe file tree traversal is breadth-first with the given FileVisitor invoked for each file encountered.
  • BIf the file is a directory, and if that directory could not be opened, the postVisitFileFailed method is
  • CThe maxDepth parameter's value is the maximum number of directories to visit.
  • DBy default, symbolic links are not automatically followed by the method.

How the community answered

(24 responses)
  • A
    17% (4)
  • B
    8% (2)
  • C
    75% (18)

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.

Topics

#walkFileTree#FileVisitor#symbolic links#maxDepth

Community Discussion

No community discussion yet for this question.

Full 1Z0-805 Practice