Java tutorial
//package com.java2s; import java.io.File; public class Main { public static boolean deleteFileDir(File dir) { if (dir == null) { return true; } File[] fList = dir.listFiles(); if (fList == null || fList.length <= 0) { return true; } for (File file : fList) { if (file == null) { continue; } if (file.isDirectory()) { if (!deleteFileDir(file)) { return false; } } else { if (!file.delete()) { return false; } } } return true; } }