从Oathy考试的"Kathy Sierra Bert Bates"一书中我发现了以下代码
public class FileTest {
public static void matches(Path path, String glob){
PathMatcher matcher = FileSystems.getDefault().getPathMatcher(glob);
System.out.println(matcher.matches(path));
}
public static void main(String[] args) throws IOException {
Path path = Paths.get("/com/java/One.java");
matches(path, "glob:*.java");
matches(path, "glob:**/*.java");
matches(path, "glob:*");
matches(path, "glob:**");
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
false
true
false
true
Run Code Online (Sandbox Code Playgroud)
我无法清楚地理解输出.有人会解释我吗?让我知道我的例子是什么是跨越目录边界.谢谢洛基