Here you can find the source of deleteFolder(final File folder)
Parameter | Description |
---|---|
folder | the folder to be deleted |
static boolean deleteFolder(final File folder)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**//from ww w. j a va2 s .c om * Deletes a folder by individually deleting each file and * subfolder folder. * * @param folder the folder to be deleted * @return true of the folder was deleted successfully */ static boolean deleteFolder(final File folder) { boolean success = false; if (folder.isDirectory()) { for (final File file : folder.listFiles()) { if (file.isDirectory()) { deleteFolder(file); } else { file.delete(); } } success = folder.delete(); } return success; } }