首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SKIP_SIBLINGS与SKIP_SUBTREE的区别

SKIP_SIBLINGS与SKIP_SUBTREE的区别
EN

Stack Overflow用户
提问于 2013-05-14 16:29:53
回答 1查看 1.9K关注 0票数 0

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

SKIP_SUBTREE -当preVisitDirectory返回此值时,将跳过指定的目录及其子目录。这枝树枝被“修剪掉”了。 SKIP_SIBLINGS -当preVisitDirectory返回此值时,指定的目录不会被访问,postVisitDirectory不会被调用,也不会再访问未访问的兄弟姐妹。如果从postVisitDirectory方法返回,则不会访问其他兄弟姐妹。本质上,在指定的目录中不再发生任何其他事情。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-14 16:40:37

你似乎回答了自己的问题,但如果甲骨文教程中的解释没有消除你的所有疑虑,那么javadoc就是这么说的:

SKIP_SUBTREE

继续,而不访问该目录中的条目。只有当从preVisitDirectory方法返回时,此结果才有意义;否则,此结果类型与返回继续相同。

SKIP_SIBLINGS

继续,而不访问此文件或目录的同级。如果从preVisitDirectory方法返回,那么目录中的条目也会被跳过,并且不会调用postVisitDirectory方法。

这是FileVisitResult的代码

代码语言:javascript
复制
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;
}

这里还有一个关于枚举的教程。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16548333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档