// using closure under groovy
// to display all contains in directory
def getFiles = { dir, rtn ->
dir.listFiles().each { file ->
if (file.isDirectory()) {
getFiles(file, rtn)
} else {
rtn.call(file) // action
}
}
}
getFiles(new File('/Users/tcchou/Desktop/ewtek'), { file ->
println file.getAbsolutePath()
})
0 comments:
Post a Comment