This should be really simple. If I have a String like this:
../Test?/sample*.txt
then what is a generally-accepted way to get a list of fil
Here are examples of listing files by pattern powered by Java 7 nio globbing and Java 8 lambdas:
try (DirectoryStream dirStream = Files.newDirectoryStream(
Paths.get(".."), "Test?/sample*.txt")) {
dirStream.forEach(path -> System.out.println(path));
}
or
PathMatcher pathMatcher = FileSystems.getDefault()
.getPathMatcher("regex:Test./sample\\w+\\.txt");
try (DirectoryStream dirStream = Files.newDirectoryStream(
new File("..").toPath(), pathMatcher::matches)) {
dirStream.forEach(path -> System.out.println(path));
}