Here you can find the source of deleteDir(File dir)
Parameter | Description |
---|---|
dir | Verzeichnis |
public static boolean deleteDir(File dir)
//package com.java2s; /*//from w w w.ja va 2s. c o m * Copyright 2005-2008 by beck et al. projects GmbH, Munich * Copyright 2009 by Kappich Systemberatung, Aachen * * This file is part of de.bsvrz.sys.funclib.losb. * * de.bsvrz.sys.funclib.losb 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. * * de.bsvrz.sys.funclib.losb 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 de.bsvrz.sys.funclib.losb. If not, see <http://www.gnu.org/licenses/>. * Contact Information: * Kappich Systemberatung * Martin-Luther-Stra?e 14 * 52062 Aachen, Germany * phone: +49 241 4090 436 * mail: <info@kappich.de> */ import java.io.File; import java.io.FileFilter; public class Main { /** * Loescht das angegebene Verzeichnis inkl. seines Inhalts rekursiv. * * @param dir Verzeichnis * * @return Erfolgs-Kennzeichen. */ public static boolean deleteDir(File dir) { if (dir.isDirectory()) { for (File f : dir.listFiles()) { if (!deleteDir(f)) return false; } } return dir.delete(); } /** * Liefert eine Array aller Dateien (ohne Unterverzeichnisse) des angegebenen Verzeichnisses. * * @param dir Verzeichnis * * @return Array von Dateien */ public static File[] listFiles(File dir) { return dir.listFiles(new FileFilter() { public boolean accept(File f) { return f.isFile(); } }); } }