gpt4 book ai didi

java - SKIP_SIBLINGS 和 SKIP_SUBTREE 之间的区别

转载 作者:行者123 更新时间:2023-12-01 14:35:04 26 4
gpt4 key购买 nike

有人知道这两者之间的区别FileVisitResult ?直接来自this甲骨文教程:

SKIP_SUBTREE – When preVisitDirectory returns this value, the specified directory and its subdirectories are skipped. This branch is "pruned out" of the tree.

SKIP_SIBLINGS – When preVisitDirectory returns this value, the specified directory is not visited, postVisitDirectory is not invoked, and no further unvisited siblings are visited. If returned from the postVisitDirectory method, no further siblings are visited. Essentially, nothing further happens in the specified directory.

最佳答案

看起来你已经回答了你自己的问题,但是如果oracle教程的解释没有消除你所有的疑问,这就是javadoc说:

SKIP_SUBTREE

Continue without visiting the entries in this directory. This result is only meaningful when returned from the preVisitDirectory method; otherwise this result type is the same as returning CONTINUE.

SKIP_SIBLINGS

Continue without visiting the siblings of this file or directory. If returned from the preVisitDirectory method then the entries in the directory are also skipped and the postVisitDirectory method is not invoked.

这是 FileVisitResult 的代码:

public enum FileVisitResult {
/**
* Continue. When returned from a {@link FileVisitor#preVisitDirectory
* preVisitDirectory} method then the entries in the directory should also
* be visited.
*/
CONTINUE,
/**
* Terminate.
*/
TERMINATE,
/**
* Continue without visiting the entries in this directory. This result
* is only meaningful when returned from the {@link
* FileVisitor#preVisitDirectory preVisitDirectory} method; otherwise
* this result type is the same as returning {@link #CONTINUE}.
*/
SKIP_SUBTREE,
/**
* Continue without visiting the <em>siblings</em> of this file or directory.
* If returned from the {@link FileVisitor#preVisitDirectory
* preVisitDirectory} method then the entries in the directory are also
* skipped and the {@link FileVisitor#postVisitDirectory postVisitDirectory}
* method is not invoked.
*/
SKIP_SIBLINGS;
}

这里还有关于 enums 的教程.

关于java - SKIP_SIBLINGS 和 SKIP_SUBTREE 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16548333/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com