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

booleandeleteFile(String filePath)
delete File
File file = new File(filePath);
if (!file.exists()) {
    return true;
} else {
    if (file.isFile()) {
        return file.delete();
    } else {
        for (File f : file.listFiles()) {
...
booleandeleteFile(String filePath)
delete File
boolean ret = true;
try {
    File file = new File(filePath);
    file.delete();
} catch (Exception e) {
    e.printStackTrace();
    ret = false;
return ret;
voiddeleteFile(String filePath)
delete File
if (null == filePath || "".equals(filePath.trim())) {
    throw new IllegalArgumentException("File Path cannot be Null/Empty");
deleteFile(new File(filePath));
booleandeleteFile(String filePath)
delete File
if (!checkFile(filePath, false)) {
    return true;
File f = new File(filePath);
return f.delete();
voiddeleteFile(String filePath)
delete File
deleteFile(filePath, false);
intdeleteFile(String filePath)
deleteFile
try {
    File file = new File(filePath);
    file.delete();
    return 1;
} catch (Exception e) {
    LAST_ERROR = e.getMessage();
    e.printStackTrace();
    return -1;
...
booleandeleteFile(String filePathAndName)
delete File
boolean flag = false;
try {
    String filePath = filePathAndName;
    File myDelFile = new File(filePath);
    if (myDelFile.exists()) {
        myDelFile.delete();
        flag = true;
    } else {
...
booleandeleteFile(String filePathName)
delete File
boolean success = (new File(filePathName)).delete();
return success;
ListdeleteFile(String p_filePath, boolean pb_recursive)
delete File
List<File> deletedFiles = new ArrayList<File>();
File file = new File(p_filePath);
deleteFile(file, pb_recursive, deletedFiles);
return deletedFiles;
voiddeleteFile(String path)
delete File
File file = new File(path);
if (file.exists()) {
    file.delete();