import java.nio.file.*;
public class GlobExample {
public static void main(String[] args) throws Exception {
FileSystem fs = FileSystems.getDefault();
PathMatcher matcher = fs.getPathMatcher("glob:*.txt");
Path dir = Paths.get("C:/data");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
for (Path file : stream) {
if (matcher.matches(file.getFileName())) {
System.out.println(file);
}
}
}
}
}