List of utility methods to do Delete File on Exit
void | deleteOnExit(File dir) delete On Exit synchronized (temporary) { if (temporary.isEmpty()) { Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { synchronized (temporary) { for (File dir : temporary) { deleteFileOrDir(dir, 256); }, "Temporary Directory Cleanup")); temporary.add(dir); |
void | deleteOnExit(File file) Delete physically the file but when the JVM exits (useful for temporary file) if (!file.exists()) { return; file.deleteOnExit(); |
void | deleteOnExit(File file) delete On Exit delete.add(file.getAbsolutePath()); |
void | deleteOnExit(final File file) Requests in privileged mode that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates. file.deleteOnExit(); |
void | deleteOnExit(final File file) Schedule a file to be deleted when JVM exits. file.deleteOnExit(); if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { deleteOnExit(child); |
void | deleteOnExitRecursive(File file) delete On Exit Recursive if (!file.exists()) return; file.deleteOnExit(); if (!file.isDirectory()) return; for (File f : file.listFiles()) deleteOnExitRecursive(f); |