File Convenience Closures - Groovin' with Groovy
import java.io.*

new File("ex16.out").withPrintWriter { w |
    w.println "This is an example of the usePrintWriter"
    w.println "available in the standard Groovy package."
}

[Example 16 Output]

Example 16