Here you can find the source of deleteFolderContents(File folder)
public static boolean deleteFolderContents(File folder)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static boolean deleteFolderContents(File folder) { File[] files = folder.listFiles(); if (files != null) { for (File file : files) { if (file.isFile()) { if (!file.delete()) { return false; }//from www . ja va 2 s. c o m } else { if (!deleteFolder(file)) { return false; } } } } return true; } public static boolean deleteFolder(File folder) { return deleteFolderContents(folder) && folder.delete(); } }