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

booleandeleteDirRecursive(String dirPath)
delete Dir Recursive
File dir = new File(dirPath);
if (dir.isDirectory()) {
    File[] children = dir.listFiles();
    for (int i = 0; i < children.length; i++) {
        boolean success = deleteDirRecursive(children[i].getAbsolutePath());
        if (!success) {
            return false;
return dir.delete();
booleandeleteDirRecursive(String path)
delete Dir Recursive
return deleteDirRecursive(new File(path));
voiddeleteDirs(File path)
delete Dirs
File[] files = null;
if (path.isDirectory()) {
    path.delete();
    files = path.listFiles();
    if (files != null) {
        for (int i = 0; i < files.length; i++) {
            deleteDirs(files[i]);
path.delete();
voiddeleteDirs(String pathname)
delete Dirs
if (pathname == null || pathname.isEmpty()) {
    return;
File path = new File(pathname);
deleteDirs(path);
booleandeleteDirWithContent(final String path)
delete Dir With Content
final File dir = new File(path);
return deleteDirWithContent(dir);
voiddeleteEmptDir(String Path, String username)
This Method is responsible for deleting the author dir in which permission given when it empty
String pathdir = Path + "/" + username;
File fdir = new File(pathdir);
Vector y = new Vector();
String ContentList[] = fdir.list();
for (int j = 0; j < ContentList.length; j++) {
    y.add(ContentList[j]);
if (y.size() == 0)
...
booleandeleteEmptyDir(File dstPath)
deletes Empty directories
Boolean result = false;
if (dstPath.exists()) {
    try {
        delete(dstPath);
    } catch (IOException e) {
        e.printStackTrace();
return result;
voiddeleteEmptyParents(final File path)
Delete path and any empty parent directories.
deleteEmptyParents(path, null);
booleandeleteFile(File path)
Delete a file or directory
if (!path.exists())
    return true;
if (path.isDirectory()) {
    File[] files = path.listFiles();
    for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory()) {
            deleteFile(files[i]);
        } else {
...
booleandeleteFile(File path)
This function will recursively delete directories and files.
if (path.exists()) {
    if (path.isDirectory()) {
        File[] files = path.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                if (!deleteFile(files[i])) {
                    try {
                        Thread.sleep(300);
...