I want to use a java 8 DirectoryStream to find files that match a glob pattern, but I want to do it in Groovy (2.4 at least). I'm having trouble finding an example of how to do it though, since try-with-resources doesn't exist in groovy.
Additionally, what if the search pattern is **/*.txt. The pattern says it should cross directory boundaries, but my understanding of the DirectoryStream is that it doesn't.
def recent = {File file -> new Date() - new Date(file.lastModified) < 7}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, job.pattern)) {
for (Path entry : stream) {
if(recent){
/*dostuff*/
}
}
}