Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; public class Main { private static ArrayList<File> filesInCache = new ArrayList<>(); public static void deleteFilesInCache() { if (filesInCache == null) { return; } else { for (File file : filesInCache) { if (!file.exists()) continue; if (file.isFile()) { file.delete(); } else if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { if (!files[i].exists()) continue; if (files[i].isFile()) { files[i].delete(); } } } } } filesInCache.clear(); } }