Here you can find the source of deleteFolder(File targetFolder)
public static boolean deleteFolder(File targetFolder)
//package com.java2s; import java.io.File; public class Main { public static boolean deleteFolder(File targetFolder) { try {//from w w w.j a va 2 s . co m File[] childFile = targetFolder.listFiles(); if (childFile == null) { return !targetFolder.exists(); } int size = childFile.length; if (size > 0) { for (int i = 0; i < size; i++) { if (childFile[i].isFile()) { childFile[i].delete(); } else { deleteFolder(childFile[i]); } } } targetFolder.delete(); } catch (Exception e) { e.printStackTrace(); } return !targetFolder.exists(); } }