This is not the case, so I assume that files contains something (e.g. null ?)
[].each { println "boom"
Assuming your files have a null list causing the problem, you can get rid of them:
files.findAll().each { filename -> def fos = new FileOutputStream( new File( targetDir, filename ) ) ...
Or, of course, do what the list generates without first adding zeros.
Edit
Actually, it looks like you have a list with empty lines in it ...
findAll should still work as empty lines are evaluated to false in Groovy Truth
Edit 2
As a quick note, you can probably change:
def fos = new FileOutputStream( new File( targetDir, filename ) ) ...
in
new File( targetDir, filename ).withOutputStream { fos -> ...
And it ensures that the stream is closed to you :-)
tim_yates
source share