Filename filter

This shows the usage of the Java FilenameFilter with groovy.

class FileFilter implements FilenameFilter {
	public boolean accept(File f, String filename) {
		return filename.endsWith("txt")
	}
}
println new File("test").list(new FileFilter())
{"test.txt"}
class FileFilter implements FilenameFilter {
	public boolean accept(File f, String filename) {
		return filename.endsWith("txt")
	}
}
new File("test").listFiles(new FileFilter()).each { file ->
	println file.getName()
}
test.txt