Created
July 23, 2014 08:49
-
-
Save yanhua365/d335dcefd80af8a03a8c to your computer and use it in GitHub Desktop.
Java和Groovy里使用FilenameFilter来查找文件 (from: http://groovycode.com/file/filename_filter)
This file contains hidden or 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
| println new File("/tmp").list({d, f-> f ==~ /.*.txt/ } as FilenameFilter) |
This file contains hidden or 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
| class FileFilter implements FilenameFilter { | |
| public boolean accept(File f, String filename) { | |
| return filename.endsWith("txt") | |
| } | |
| } | |
| println new File("directory").list(new FileFilter()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment