Java tutorial
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.io.File; public class Main { /** * 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; } } } }