Java File Path Delete deleteDirs(String pathname)

Here you can find the source of deleteDirs(String pathname)

Description

delete Dirs

License

Apache License

Declaration

public static void deleteDirs(String pathname) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    public static void deleteDirs(String pathname) {
        if (pathname == null || pathname.isEmpty()) {
            return;
        }//from  ww w  .j a  v a 2s .c  om
        File path = new File(pathname);
        deleteDirs(path);
    }

    public static void deleteDirs(File path) {
        if (!path.exists())
            return;
        if (path.isFile()) {
            path.delete();
            return;
        }
        File[] files = path.listFiles();
        for (File file : files) {
            deleteDirs(file);
        }
        path.delete();
    }
}

Related

  1. deleteDirectoryRecursivly(String path)
  2. deleteDirectoryTree(String directoryPath)
  3. deleteDirRecursive(String dirPath)
  4. deleteDirRecursive(String path)
  5. deleteDirs(File path)
  6. deleteDirWithContent(final String path)
  7. deleteEmptDir(String Path, String username)
  8. deleteEmptyDir(File dstPath)
  9. deleteEmptyParents(final File path)