groovy> import groovy.io.FileType
groovy> class Foo {
groovy> def java.lang.String path
groovy> def java.lang.String pattern
groovy> def java.lang.String replacement
groovy> def list = []
groovy>
groovy> File dir = new File(path)
groovy>
groovy> // dir.eachFileRecurse (FileType.FILES) // gets subdirs
groovy> dir.eachFile( FileType.FILES)
groovy> {
groovy>
groovy> file ->
groovy> if (file.name.endsWith("txt")) list << file
groovy> }
groovy> }
groovy> // this works
groovy> def f = new Foo(path: "L:\\tmp", pattern: "this", replacement: "that")
groovy> println f.path
groovy> println f.pattern
groovy> println f.replacement
groovy> //Afterwards the list variable contains all txt files (java.io.File) of
the given directory (and its subdirectories with Recurse):
groovy> f.list.each {
groovy> println it.path
groovy> }
1 compilation error:
unexpected token: dir at line: 13, column: 9