Skip to content

Instantly share code, notes, and snippets.

@yanhua365
Created July 23, 2014 08:49
Show Gist options
  • Select an option

  • Save yanhua365/d335dcefd80af8a03a8c to your computer and use it in GitHub Desktop.

Select an option

Save yanhua365/d335dcefd80af8a03a8c to your computer and use it in GitHub Desktop.
Java和Groovy里使用FilenameFilter来查找文件 (from: http://groovycode.com/file/filename_filter)
println new File("/tmp").list({d, f-> f ==~ /.*.txt/ } as FilenameFilter)
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