Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void deleteFile(File file) { if (file.exists()) { if (file.isDirectory()) { File[] files = file.listFiles(); for (File file2 : files) { if (file2.isDirectory()) { deleteFile(file2); } else { file2.deleteOnExit(); } } } file.deleteOnExit(); } } }