Created
February 10, 2014 08:12
-
-
Save AlexanderEkdahl/8912142 to your computer and use it in GitHub Desktop.
FileFinder by Fredrik Sydvart and AlexanderEkdahl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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