When we write code in Java to work with files we must write a lot of boilerplate code to make sure all streams are opened and closed correctly and provide exception handling. The Commons IO package already helps, but Groovy makes working with files so easy. Groovy adds a lot of useful methods to thejava.io.File class. We can use simple properties to write and read text, methods to traverse the file system and methods to filter contents.
Here is a Groovy script with different samples of working with files:
* Working with the GDK - Working with files and I/O
* The Simple Groovy datatypes - Working with regular expressions