Delete directory recursively
import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; public class Main { public static void main(String[] args) throws Exception { File directory = new File("c:\\"); FileUtils.deleteDirectory(directory); } }