Here you can find the source of deleteRecursiveDirectories(String mainDir)
public static void deleteRecursiveDirectories(String mainDir)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void deleteRecursiveDirectories(String mainDir) { File dir = new File(mainDir); File subDir1 = new File(dir.getAbsolutePath() + "\\subdir1"); File subDir2 = new File(dir.getAbsolutePath() + "\\subdir2"); File tempFile1 = new File(dir.getAbsolutePath() + "\\file1.txt"); File tempFile2 = new File(subDir1.getAbsolutePath() + "\\file2.txt"); tempFile1.delete();/*from ww w . ja v a2 s .c o m*/ tempFile2.delete(); subDir1.delete(); subDir2.delete(); dir.delete(); } }