Java Delete Temp File deleteTempFiles()

Here you can find the source of deleteTempFiles()

Description

Deletes all temporary files created by the current thread using #createTempFile .

License

Open Source License

Declaration

public static void deleteTempFiles() 

Method Source Code


//package com.java2s;

import java.io.File;

import java.util.ArrayList;

public class Main {
    /** Used to track temp files, per thread */
    private static ThreadLocal<ArrayList<File>> tempFiles = new ThreadLocal<ArrayList<File>>();

    /**/*from w ww  .  jav  a2 s . c  om*/
     * Deletes all temporary files created by the current thread using
     * {@link #createTempFile}.
     */
    public static void deleteTempFiles() {
        ArrayList<File> files = tempFiles.get();
        if (files != null) {
            for (File f : files)
                f.delete();
            files.clear();
            tempFiles.set(null);
        }
    }
}

Related

  1. deleteTempFile(final File tempFile)
  2. deleteTempFile(String fileId)
  3. deleteTempFiles()
  4. deleteTempFiles()
  5. deleteTempFiles()
  6. deleteTempFiles(final File workFolder)
  7. deleteTempFiles(Map fileMap, String templateFileName)