Here you can find the source of deleteDir(File path)
public static boolean deleteDir(File path)
//package com.java2s; /*// w ww . ja v a2 s .c om * This file is part of SimpleClans2 (2012). * * SimpleClans2 is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * SimpleClans2 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SimpleClans2. If not, see <http://www.gnu.org/licenses/>. * * Last modified: 10.10.12 21:57 */ import java.io.File; public class Main { public static boolean deleteDir(File path) { if (path == null || !path.isDirectory()) { return false; } File[] files = path.listFiles(); for (File file : files) { if (file.isDirectory()) { deleteDir(file); } if (!file.delete()) { return false; } } return path.delete(); } }