为什么 glob:* 不匹配 PathMatcher 中的任何路径?

Why doesn't glob:* match any path in PathMatcher?

让我们有:

Path path = Paths.get("C:\1.txt");

以下代码打印 "true":

PathMatcher matcher = FileSystems.getDefault().getPathMatcher("regex:.*");
System.out.println(matcher.matches(path));

但是下面的代码打印 "false":

PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:*");
System.out.println(matcher.matches(path));

为什么?

我希望在这两种方法中都有 true

根据Glob page from Wikipedia,通配符*表示:

matches any number of any characters including none

详情:

正如@T.J Crowder 所说,你应该接受这个:

PathMatcher matcher2 = FileSystems.getDefault().getPathMatcher("glob:**");
System.out.println(matcher2.matches(path));

有关详细信息,请参阅 this,其中显示:

The ** characters matches zero or more characters crossing directory boundaries.