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

booleandeleteRecursive(File path, boolean debug)
delete Recursive
if (!path.exists()) {
    return true;
boolean ret = true;
if (path.isDirectory()) {
    for (File f : path.listFiles()) {
        ret = ret && deleteRecursive(f, debug);
if (debug)
    out.println("deleting " + path);
return ret && path.delete();
voiddeleteRecursively(File path)
Delete the specified directory/file.
if (path.isDirectory()) {
    for (File child : path.listFiles())
        deleteRecursively(child);
if (!path.delete())
    throw new RuntimeException("Failed to delete this file/directory: " + path.getAbsolutePath());
voiddeleteRecursively(File path, File parentCanonical)
Deletes a file or sub-directory recursively, but does not follow links within the directory structure.
if (!path.exists())
    return;
else if (!path.isDirectory()) {
    if (!path.delete())
        throw new IOException("Could not delete file " + path);
} else {
    File canonical = path.getCanonicalFile();
    File realParent = canonical.getParentFile();
...
voiddeleteSelectedFilesFromDirectory(final String directoryPath, final List filesList)
delete Selected Files From Directory
final File directory = new File(directoryPath);
if (directory != null && directory.exists()) {
    for (final File file : directory.listFiles()) {
        if (filesList == null || filesList.isEmpty() || !filesList.contains(file.getName())) {
            file.delete();
voiddeleteSubfiles(String publishTemppath)
delete Subfiles
File file = new File(publishTemppath);
if (!file.exists() || file.isFile())
    return;
File[] files = file.listFiles();
for (int i = 0; files != null && i < files.length; i++) {
    File temp = files[i];
    if (temp.isDirectory()) {
        deleteSubfiles(temp.getAbsolutePath());
...
FiledeleteTemp(String tempPath)
delete Temp
File tempFile = new File(tempPath);
if (tempFile.exists()) {
    deleteFile(tempFile);
return tempFile;
voiddeleteTempDataFile(String dataFilePath)
delete Temp Data File
File dataFile = new File(dataFilePath);
dataFile.delete();
voiddeleteTempFile(String sourceFilePath)
DeleteTempFile(String sourceFilePath) method is responsible delete content file
File tempfile = new File(sourceFilePath);
if (tempfile.exists()) {
    tempfile.delete();
voiddeleteTree(final File path)
Delete all files recursively within tree.
if (path.exists()) {
    if (path.isDirectory()) {
        File[] files = path.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                deleteTree(files[i]);
            } else {
                files[i].delete();
...
booleandeleteWallpaper(String file_name, Map dimmensions, String basepath, List resolution_directories)
deletes a wallpaper and all its copies
Set<Entry<String, Integer>> entrySet = dimmensions.entrySet();
Iterator<Entry<String, Integer>> entries = entrySet.iterator();
while (entries.hasNext()) {
    Entry<String, Integer> e = entries.next();
    File rez = new File(basepath + File.separator + e.getKey() + File.separator + file_name);
    if (rez.exists() && !rez.delete()) {
        rez.deleteOnExit();
        return false;
...