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(File path, boolean deleteMyself, boolean deleteHidden)
delete Directory
if (path.exists()) {
    File[] files = path.listFiles();
    for (int i = 0; i < files.length; i++) {
        if (deleteHidden || !files[i].getName().startsWith(".")) {
            if (files[i].isDirectory()) {
                deleteDirectory(files[i], true, deleteHidden);
            } else {
                files[i].delete();
...
booleandeleteDirectory(File path, boolean includeDir)
delete Directory
boolean success = true;
if (path.exists()) {
    File[] files = path.listFiles();
    for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory()) {
            success = deleteDirectory(files[i], true) && success;
        } else {
            success = files[i].delete() && success;
...
booleandeleteDirectory(final File path)
Uses an iterative algorithm to recursively delete an entire directory and all its subdirectories.
if (!path.isDirectory())
    throw new IllegalArgumentException("path must be a directory");
if (path == null)
    return false;
if (!path.exists())
    return true;
try {
    File curr;
...
booleandeleteDirectory(final File path)
delete Directory
if (path.exists()) {
    final File[] files = path.listFiles();
    if (files != null) {
        for (final File file : files) {
            if (file.isDirectory()) {
                deleteDirectory(file);
            } else {
                file.delete();
...
booleandeleteDirectory(final String directoryPath)
delete Directory
return deleteDirectory(new File(directoryPath));
booleandeleteDirectory(final String fullDirPath)
delete Directory
String sp = System.getProperty("file.separator");
File texDir = new File(fullDirPath);
if (texDir.exists() && texDir.isDirectory()) {
    String[] dirList = texDir.list();
    for (String aDirList : dirList) {
        String myDirPath = texDir.getAbsolutePath() + sp + aDirList;
        File d = new File(myDirPath);
        if (d.exists() && d.isDirectory()) {
...
voiddeleteDirectory(final String path)
Deletes a file or directory
File file = new File(path);
deleteDirectory(file);
booleandeleteDirectory(String dir_path)
Utilitary method to delete the directory corresponding to the given path
return deleteDirectory(new File(dir_path));
booleanDeleteDirectory(String directoryPath)
Remove a directory and all of its contents.
if (directoryPath == null || directoryPath.isEmpty()) {
    return false;
File directory = new File(directoryPath);
if (directory == null)
    return false;
if (!directory.exists())
    return true;
...
booleandeleteDirectory(String directoryPath)
delete Directory
File directory = new File(directoryPath);
if (directory.isDirectory()) {
    if (directory.listFiles().length == 0) {
        return delete(directory, true);
return false;