Recursive Delete File : File Commands « File Input Output « Java
- Java
- File Input Output
- File Commands
Recursive Delete File
import java.io.File;
public class Util{
public static boolean recursiveDeleteFile(File path) {
if( path.exists() ) {
if (path.isDirectory()) {
File[] files = path.listFiles();
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory()) {
recursiveDeleteFile(files[i]);
} else {
files[i].delete();
}
}
}
}
return(path.delete());
}
}
Related examples in the same category