我有:
Path path = Paths.get("Foo.class");
Path path2 = Paths.get("Foo.java");
FileSystem fs = FileSystems.getDefault();
PathMatcher matcher = fs.getPathMatcher("glob:*.{class, java}");
matcher.matches(path); // TRUE
matcher.matches(path_2); // FALSE
如果glob语法{}表示它匹配.class或.java,为什么
path2
为false?从jdk documentation:
*。{java,class}匹配以.java或.class结尾的文件名
最佳答案
这是因为class, java
中的空格
关于java - Java NIO.2 Glob问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6569397/