harry21
8 years agoOccasional Contributor
Groovy to delete all the files in a directory
Can someone direct me how to delete all the files in a directory.. (As a prerequisite, this needs to be done before running each testcase) I've googled it and couldn't get the relevant answer. I tri...
- 8 years ago
You are missing a couple of points here.
- You need to import the FileUtils class to use it.
- You cleanDirectory method accepts File data type, and you seem to try and pass a string.
Here is a snippet that should work:
import org.apache.commons.io.FileUtils File folder = new File("C:/Work/composite") FileUtils.cleanDirectory(folder)
There probably is a shorter way, but this seems clean enough :)