Reputation: 71
I have written a closure within a Groovy script to copy files, and then I pass that closure to eachFileMatch(regex, closure) to copy all files that match the given regex. When I prototyped it in the Groovy Console everything worked just fine but now when I run it in Eclipse I get the following error:
groovy.lang.MissingMethodException: No signature of method: java.lang.String.eachFileMatch() is applicable for argument types: (java.util.regex.Pattern, file_copy$_run_closure3)
Here is the closure and the call to eachFileMatch()
def fileCopyClosure = {
if(it.canRead()){
def destFolder = new File("${outputDirectory}")
if(!destFolder.exists()){
println "Creating directory"
destFolder.mkdir()
}
def desti = new File("${outputDirectory}\\${it.name}")
output = desti.newOutputStream()
it.eachByte(1024, write)
output.close()
}
}
sourceDir.eachFileMatch(regex, fileCopyClosure)
Upvotes: 1
Views: 402
Reputation: 171054
from the exception, sourceDir
is a String, not a File
that you need for eachFileRecurse
Upvotes: 0