groovycode.com

Delete a file with groovy

Delete a file from disk with groovy.

1 String filename = "test.txt"  
2 // this deletes the file test.txt  
3 boolean fileSuccessfullyDeleted =  new File(filename).delete()  
4 println fileSuccessfullyDeleted

false