Listing a directory the Java way
List the contents of a directory with groovy using the built in methods of Java. The groovy way is described in the following snippetsList files of a specific type, List directory contents and list files recursively.
The list method creates a String[] array of all files in a directory.
// returns String[] array
println new File("test").list()
{"bar", "foo", "test.txt"}
// returns a File[] array
new File("test").listFiles().each { file ->
println file.getName()
}
bar foo test.txt