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);
}
}
}