Here you can find the source of deleteDir(File dir)
Parameter | Description |
---|---|
dir | target directory |
public static boolean deleteDir(File dir)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.io.File; public class Main { /**/*from w w w . j a v a 2 s . c om*/ * deletes all Files and Subfolders in a directory * @param dir target directory * @return */ public static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] entries = dir.list(); for (int x = 0; x < entries.length; x++) { File aktFile = new File(dir.getPath(), entries[x]); deleteDir(aktFile); } if (dir.delete()) { return true; } else { return false; } } else { if (dir.delete()) { return true; } else { return false; } } } }