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

voiddeleteFolder(String path)
delete Folder
deleteFolder(new File(path));
booleandeleteFolder(String path)
Delete all files and folders in the directory.
boolean flag = true;
File dirFile = new File(path);
if (!dirFile.isDirectory()) {
    return flag;
File[] files = dirFile.listFiles();
for (File file : files) {
    if (file.isFile()) {
...
intdeleteFolder(String path)
deleteFolder
int res = 1;
File dir = new File(path);
String[] files = dir.list();
if (files != null && files.length > 0) {
    for (int i = 0; i < files.length; i++) {
        File temp = new File(path + "/" + files[i]);
        if (temp.isDirectory()) {
            res += deleteFolder(temp.getAbsolutePath());
...
booleandeleteFolder(String path)
delete Folder
if (path != null && storageReady()) {
    File dir = new File(path);
    if (dir.exists() && dir.isDirectory()) {
        File[] files = dir.listFiles();
        for (File file : files) {
            if (!file.delete()) {
    return dir.delete();
} else {
    return false;
voiddeleteFolder(String pathToRootFolder)
delete Folder
File rootFolder = new File(pathToRootFolder);
deleteFolder(rootFolder);
voiddeleteFolder(String pFolderPath)
delete Folder
File file = new File(pFolderPath);
file.delete();
for (int i = 0; file != null && file.isDirectory() && i < file.listFiles().length; i++) {
    deleteFolder(file.listFiles()[i].getAbsolutePath());
    file.delete();
file.delete();
booleandeleteFolder(String sPath)
delete Folder
boolean flag = false;
File file = new File(sPath);
if (!file.exists()) {
    return flag;
} else {
    if (file.isFile()) {
        return deleteFile(sPath);
    } else {
...
voiddeleteFolderAndContent(String folderPath)
Function that deletes a folder and its content.
File index = new File(folderPath);
String[] entries = index.list();
for (String s : entries) {
    File currentFile = new File(index.getPath(), s);
    currentFile.delete();
index.delete();
booleandeleteFolderRec(File path, boolean alsoDeleteGivenFolder)
This function will recursively delete directories and files.
boolean ok;
if (path.exists()) {
    ok = true;
    if (path.isDirectory()) {
        File[] files = path.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                deleteFolderRec(files[i], true);
...
voiddeleteFolderRecursively(File path, boolean includeSelf)
Deletes directory at path recursively.
if (!path.isDirectory())
    throw new IllegalArgumentException("The passed file is not a directory.");
File[] files = path.listFiles();
if (files == null)
    return;
for (int i = 0; i < files.length; i++) {
    File f = files[i];
    if (f.isFile()) {
...