Searching files in Groovy

I have recently had to update several configuration files for my company application.

At first I tried to write a simple Java application, but even with Java8 you have to write the code to iterate through the folders to look for the configuration files.

So I searched in Groovy documentation if there were some methods to help me.  I found eachFileRecursive  that is called for each file inside a folder and sub-folders recursively:


File folder = new Folder("mypath")

folder.eachFileRecurse { file ->
if(file.absolutePath.contains(".svn")) return 

if( == "abc.xml") doSomething(file)

It really helped me these days.






Leave a Comment

Your email address will not be published. Required fields are marked *