Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void deleteDirectory(File directory) { if (directory.exists()) { File[] files = directory.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { deleteDirectory(file); } else { file.delete(); } } } } directory.delete(); } }