import java.nio.file.*; import java.util.stream.*; public class GlobExample { public static void main(String[] args) throws Exception { PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:**/*.txt"); Path startingDir = Paths.get("path/to/directory"); try (Stream<Path> paths = Files.walk(startingDir)) { paths.filter(pathMatcher::matches) .forEach(System.out::println); } } }


上一篇:
下一篇:
切换中文