Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static boolean deleteFileOrDir(File path) { if (path == null || !path.exists()) { return true; } if (path.isFile()) { return path.delete(); } File[] files = path.listFiles(); if (files != null) { for (File file : files) { deleteFileOrDir(file); } } return path.delete(); } }