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

booleandeleteAllFile(String folderPath)
delete All File
boolean bool = false;
File file = new File(folderPath);
if (!file.exists())
    return false;
if (!file.isDirectory())
    return false;
String[] tempList = file.list();
File temp = null;
...
booleandeleteAllFile(String path)
Delete all files
boolean success = true;
File file = new File(path);
if (!file.exists()) {
    success = false;
if (!file.isDirectory()) {
    success = false;
if (success) {
    String[] tempList = file.list();
    File temp = null;
    for (int i = 0; i < tempList.length; i++) {
        if (path.endsWith(File.separator)) {
            temp = new File(path + tempList[i]);
        } else {
            temp = new File(path + File.separator + tempList[i]);
        if (temp.isFile()) {
            success &= temp.delete();
return success;
booleandeleteAllFile(String path)
delete All File
boolean flag = false;
File file = new File(path);
if (!file.exists()) {
    return flag;
if (!file.isDirectory()) {
    return flag;
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++) {
    if (path.endsWith(File.separator)) {
        temp = new File(path + tempList[i]);
    } else {
        temp = new File(path + File.separator + tempList[i]);
    if (temp.isFile()) {
        temp.delete();
    if (temp.isDirectory()) {
        deleteAllFile(path + "/" + tempList[i]);
        deleteFolder(path + "/" + tempList[i]);
        flag = true;
return flag;
voiddeleteAllFiles()
delete All Files
deleteJavaFiles();
deleteF3Files();
deleteClassFiles();
deleteJarFiles();
voiddeleteAllFiles(File dir)
remove the whole directory
if (dir == null)
    return;
File[] list = dir.listFiles();
if (list == null)
    return;
for (File i : list) {
    if (i.isFile()) {
        i.delete();
...
voiddeleteAllFiles(File directory)
Delete all files in a directory (not recursive).
File[] fileList = directory.listFiles();
if (fileList == null) {
    return;
File file;
for (int i = 0; i < fileList.length; i++) {
    file = fileList[i];
    if (file.isFile()) {
...
voiddeleteAllFiles(File directory)
Dlete all files and directory from directory
File[] fs = directory.listFiles();
if (fs != null) {
    for (int i = 0; i < fs.length; i++) {
        fs[i].delete();
voiddeleteAllFiles(File dirOrFile)
Recursively delete all the files and folders under dirOrFile
if (!dirOrFile.exists())
    return;
if (dirOrFile.isFile()) {
    dirOrFile.delete();
} else
    if ((dirOrFile.listFiles() != null) && (dirOrFile.listFiles().length > 0)) {
        File[] fileList = dirOrFile.listFiles();
...
booleandeleteAllFiles(String directory)
delete All Files
File file = new File(directory);
if (file.isDirectory() && file.exists()) {
    String[] files = file.list();
    boolean flag = true;
    String[] arr$ = files;
    int len$ = files.length;
    for (int i$ = 0; i$ < len$; ++i$) {
        String item = arr$[i$];
...
voiddeleteAllFiles(String folder, String type)
delete All Files
File src = new File(folder);
String[] files = src.list();
for (String f : files) {
    if (new File(folder + File.separator + f).isDirectory()) {
        deleteAllFiles(folder + File.separator + f, type);
    } else if (f.endsWith(type)) {
        new File(folder + File.separator + f).delete();