Java Utililty Methods Delete Temp File

List of utility methods to do Delete Temp File

Description

The list of methods to do Delete Temp File are organized into topic(s).

Method

voiddeleteTempFile()
delete Temp File
try {
    File f = new File(fileName);
    f.delete();
} catch (Exception e) {
booleandeleteTempFile(File f)
delete Temp File
if (f == null) {
    return false;
f.deleteOnExit();
f.delete();
if (f.exists()) {
    return false;
} else {
...
booleandeleteTempFile(final File tempFile)
Delete temp file.
boolean isDeleted = false;
if (tempFile != null && tempFile.exists()) {
    isDeleted = tempFile.delete();
return isDeleted;
voiddeleteTempFile(String fileId)
delete Temp File
File tempFile = new File(getTempDirectory(), fileId);
if (tempFile.exists()) {
    tempFile.delete();
voiddeleteTempFiles()
Deletes all temporary files created by the current thread using #createTempFile .
ArrayList<File> files = tempFiles.get();
if (files != null) {
    for (File f : files)
        f.delete();
    files.clear();
    tempFiles.set(null);
voiddeleteTempFiles()
delete Temp Files
File source = new File(getTempSourceFile());
File tmpPdf = new File(getTempPDFFile());
if (source.exists()) {
    source.delete();
if (tmpPdf.exists()) {
    tmpPdf.delete();
voiddeleteTempFiles()
delete Temp Files
deleteFile(TMP);
voiddeleteTempFiles()
delete Temp Files
File file = createTempFile("test", "test");
String folder = getDirectoryForFile(file.getAbsolutePath());
String[] list = new File(folder).list(new FilenameFilter() {
    public boolean accept(File dir, String name) {
        return name.startsWith("ohfu-");
});
if (list != null) {
...
booleandeleteTempFiles(final File workFolder)
This method deletes all the content in a folder, without the need of passing it a PlanetsLogger instance!
if (workFolder.isDirectory()) {
    File[] entries = workFolder.listFiles();
    for (int i = 0; i < entries.length; i++) {
        File current = entries[i];
        boolean deleteTempFiles = deleteTempFiles(current);
        if (!deleteTempFiles) {
            return false;
        } else {
...
voiddeleteTempFiles(Map fileMap, String templateFileName)
delete Temp Files
boolean isSuccess = true;
Iterator<File> fileIt = fileMap.values().iterator();
while (fileIt.hasNext()) {
    File file = fileIt.next();
    isSuccess = file.delete();
File file = new File(templateFileName);
try {
...