Java tutorial
//package com.java2s; import java.io.File; public class Main { /** Delete files or folders */ public static boolean deleteFiles(final String path) { boolean ret = true; File f = new File(path); if (!f.exists()) return true; if (!f.isDirectory()) { ret = f.delete() == false || ret == false ? false : true; } else { File[] files = f.listFiles(); if (files != null) { // Get folders list for (int i = 0; i < files.length; i++) { ret = deleteFiles(files[i].getPath()) == false || ret == false ? false : true; if (ret == false) return false; } } ret = f.delete() == false || ret == false ? false : true; } return ret; } }