Java Utililty Methods File Path Delete

List of utility methods to do File Path Delete

Description

The list of methods to do File Path Delete are organized into topic(s).

Method

voiddeleteDirectory(String dirPath)
delete Directory
recursiveDeleteFile(new File(dirPath));
voiddeleteDirectory(String dirPath)
delete Directory
deleteDirectory(new File(dirPath));
voiddeleteDirectory(String filePath)
delete Directory
if (!filePath.endsWith(File.separator)) {
    filePath = filePath + File.separator;
File file = new File(filePath);
if (!file.exists() && !file.isDirectory()) {
    return;
} else {
    File[] fl = file.listFiles();
...
booleandeleteDirectory(String path)
Delete the directory by a given file path.
if (!path.endsWith(File.separator)) {
    path = path + File.separator;
File dirFile = new File(path);
if (!dirFile.exists() || !dirFile.isDirectory()) {
    return false;
boolean flag = true;
...
booleandeleteDirectory(String path)
delete Directory
boolean isOk = false;
try {
    File dir = new File(path);
    if (dir.isDirectory()) {
        String[] children = dir.list();
        for (int i = 0; i < children.length; ++i) {
            boolean success = deleteDirectory(new File(dir, children[i]).getAbsolutePath());
            if (!(success)) {
...
booleandeleteDirectory(String path)
delete Directory
return deleteDirectory(new File(path));
voiddeleteDirectory(String path)
delete Directory
File file = new File(path);
File[] contents = file.listFiles();
if (contents != null) {
    for (File f : contents) {
        deleteDirectory(f.getPath());
file.delete();
...
intdeleteDirectory(String path)
delete Directory
File dir = new File(path);
if (!dir.exists() || !dir.isDirectory())
    return 4;
if (deleteStuffRecursive(dir)) {
    return 0;
return 1;
voiddeleteDirectory(String path)
delete Directory
File dirToDel = new File(path);
if (dirToDel.exists()) {
    List<File> files = getFilesInDir(dirToDel);
    for (File f : files) {
        f.delete();
    dirToDel.delete();
voiddeleteDirectory(String path)
delete Directory
Runtime.getRuntime().exec("rm -rf " + path);