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(File path)
delete File
if (!path.exists()) {
    throw new FileNotFoundException(path.getAbsolutePath());
boolean ret = true;
if (path.isDirectory()) {
    for (File f : path.listFiles()) {
        ret = ret && deleteFile(f);
return ret && path.delete();
booleandeleteFile(final String dirPath, final String fileName)
delete File
boolean ifDel = false;
final File file = new File(dirPath + "/" + fileName);
if (file.exists()) {
    ifDel = file.delete();
return ifDel;
booleandeleteFile(final String filePathName)
delete File
if (doesFileExist(filePathName)) {
    File file = new File(filePathName);
    return file.delete();
return true;
voidDeleteFile(String _filePath)
Delete File
if (_filePath == null || _filePath.isEmpty()) {
    return;
File file = new File(_filePath);
if (file.exists()) {
    try {
        if (!file.delete()) {
    } catch (Exception e) {
        e.printStackTrace();
booleandeletefile(String delpath)
deletefile
try {
    File file = new File(delpath);
    if (!file.isDirectory()) {
        file.delete();
    } else if (file.isDirectory()) {
        String[] filelist = file.list();
        for (int i = 0; i < filelist.length; i++) {
            File delfile = new File(delpath + "/" + filelist[i]);
...
voiddeleteFile(String filePath)
delete File
File f = new File(filePath);
if (!f.exists()) {
    logError("Delete: no such file or directory: " + filePath);
if (!f.canWrite()) {
    logError("Delete: write protected: " + filePath);
if (f.isDirectory()) {
...
booleandeleteFile(String filePath)
Delete the file targeted by the filePath
File fileToDelete = new File(filePath);
if (!fileToDelete.isFile())
    return false;
return fileToDelete.delete();
booleandeleteFile(String filePath)
delete File
if (filePath == null)
    return true;
File f = new File(filePath);
if (f.exists()) {
    return f.delete();
return true;
booleandeleteFile(String filePath)
delete File
if (filePath != null) {
    File f = toFile(filePath);
    if (f.exists()) {
        return f.delete();
return false;
booleandeleteFile(String filePath)
delete File
boolean isSuc = false;
try {
    File file = new File(filePath);
    if (!file.exists()) {
        file.mkdirs();
    File[] files = file.listFiles();
    for (int i = 0; i < files.length; i++) {
...