File lstFile = new File(lstFileName).withWriter{out->
archivedFiles.each {out.println it.name}
}
archivedFiles is a List objects .. I am getting an error that says:
Cannot cast object with class 'java.util.ArrayList' to class 'java.io.File'.
I am only interested in writing out file names contained in the list to the NEWLY created file
That’s beacuse the
withWriterblock is returning the last thing in the block by default (which is thearchivedFileslist)To do what you’re trying to do, you’d need to do:
or this should work too: