我研究全球模式。
我写了一个简单的例子:
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:D:\folder1\folder2\**");
boolean isMatches = matcher.matches(Paths.get("D:\folder1\folder2\folder3"));
System.out.println(isMatches);
此代码返回false
。
如果我在pattern -中使用一个星号,我将看到相同的结果。
我做错了什么?
尝试在路径表达式中使用\\
来转义目录和正则表达式
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:D:\\dev\\server\\**");
boolean isMatches = matcher.matches(Paths.get("D:\dev\server\web"));
System.out.println(isMatches);