I use this code to delete all files:
File root = new File(\"root path\");
File[] Files = root.listFiles();
if(Files != null) {
int j;
for(j = 0; j < F
For your case, this works perfectly http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#cleanDirectory(java.io.File)
File dir = new File("dir_path");
if(dir.exists() && dir.isDirectory()) {
FileUtils.cleanDirectory(dir);
}
If you wanna delete the folder itself. (It does not have to be empty). Can be used for files too.
http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#forceDelete(java.io.File)
File dir = new File("dir_path");
if(dir.exists()) {
FileUtils.forceDelete(dir);
}