[英]Why does PathMatcher doesn't match path?
I research glob patterns. 我研究glob模式。
I wrote simple example: 我写了一个简单的例子:
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:D:\\folder1\\folder2\\**");
boolean isMatches = matcher.matches(Paths.get("D:\\folder1\\folder2\\folder3"));
System.out.println(isMatches);
This code returns false
. 此代码返回
false
。
If I use one star in pattern - I see same result. 如果我在模式中使用一颗星-我会看到相同的结果。
What do I wrong? 我怎么了
Try with \\\\\\\\
in path expression, to escape directory and reg expression 尝试在路径表达式中使用
\\\\\\\\
,以转义目录和reg表达式
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:D:\\\\dev\\\\server\\\\**");
boolean isMatches = matcher.matches(Paths.get("D:\\dev\\server\\web"));
System.out.println(isMatches);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.