groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonard Brünings <>
Subject collectFilesRecurse
Date Sat, 20 Jan 2018 16:59:56 GMT
There is currently no good way to recursively scan through a
directory-structure and collect files/results.

File.eachFileRecurse and all of the overloads and derivatives don't
return a result, and thus makes it awkward
to use in a streaming fashion. One needs to create an external container
and use it in the closure to collect its results.

I propose adding a new collectFilesRecurse(Filetype,Closure) [along with
its overloads and derivatives]
which works like Iterables.findResults, in that it only collect non-null


// Current Groovy

List<String> input // some list of files

List<File> resultsFiles = []

  new File(it)
}.eachFileRecurse {
  if ('.properties')) {
    results << it

List<Properties> results = resultFiles.collect {

// With collectFileRecurse

List<Properties> results = input.collect{
  new File(it)
}.collectFileRecurse {'.properties') ? it : null
}.collect {



View raw message