Java tutorial
//package com.java2s; import java.io.File; public class Main { public static void deleteCache(File cacheDir) { try { File[] files = cacheDir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isFile()) { files[i].delete(); } if (files[i].isDirectory()) { deleteCache(files[i]); } } } catch (Exception ex) { ex.printStackTrace(); } } }