Java File Path Delete deleteTemp(String tempPath)

Here you can find the source of deleteTemp(String tempPath)

Description

delete Temp

License

Open Source License

Declaration

public static File deleteTemp(String tempPath) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static File deleteTemp(String tempPath) {
        File tempFile = new File(tempPath);
        if (tempFile.exists()) {
            deleteFile(tempFile);/*from  w w w.  j  av  a 2 s  .c  o m*/
        }
        return tempFile;
    }

    private static void deleteFile(File file) {
        if (file.exists()) {
            if (file.isFile()) {
                file.delete();
            } else if (file.isDirectory()) {
                File[] files = file.listFiles();
                if (files != null) {
                    for (File file1 : files) {
                        deleteFile(file1);
                    }
                }
                file.delete();
            }
        }
    }
}

Related

  1. deleteRecursive(File path, boolean debug)
  2. deleteRecursively(File path)
  3. deleteRecursively(File path, File parentCanonical)
  4. deleteSelectedFilesFromDirectory(final String directoryPath, final List filesList)
  5. deleteSubfiles(String publishTemppath)
  6. deleteTempDataFile(String dataFilePath)
  7. deleteTempFile(String sourceFilePath)
  8. deleteTree(final File path)
  9. deleteWallpaper(String file_name, Map dimmensions, String basepath, List resolution_directories)