How to recursively repeat files in Groovy?

Can I iterate files in Groovy? I am currently using FileUtils.iterateFiles()from Apache commons-io, but maybe there is some Groovy-native alternative for the same?

+5
source share
1 answer

Absolutely, you should check the documentation for the file in Groovy. It is available here and gives you several different helper methods for recursively iterating over a file structure.

// Simplest possible example, iterating over each file in every subfolder
new File('.').eachFileRecurse { println it.name }
+13
source

All Articles