Skip to content

Instantly share code, notes, and snippets.

@AlexanderEkdahl
Created February 10, 2014 08:12
Show Gist options
  • Save AlexanderEkdahl/8912142 to your computer and use it in GitHub Desktop.
Save AlexanderEkdahl/8912142 to your computer and use it in GitHub Desktop.
FileFinder by Fredrik Sydvart and AlexanderEkdahl
package hollow.harddrives.IO;
import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.FileSystems;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
public class FileFinder {
public static File[] findAll(String glob) {
final PathMatcher matcher = FileSystems.getDefault().getPathMatcher(
"glob:" + glob);
File dir = new File(System.getProperty("user.dir"));
return dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String filename) {
return matcher.matches(Paths.get(filename));
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment