How to efficiently find all files that match a given glob pattern in Java?
I'm writing a Java program that takes a glob pattern as the input, finds all files that match the pattern and executes an action for each of those files. I already know how to check whether one specific file matches the pattern using a PathMatcher, and I also know how to use Files.walkFileTree and a custom SimpleFileVisitor in order to iterate over all files on the file system. The naïve approach is to just do a file walk for each root directory and check for each file individually whether it matches the glob: @Test public void findFilesMatchingGlob() throws IOException { PathMatcher matcher =
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.