Here you can find the source of deleteFolder(File file)
Parameter | Description |
---|---|
file | The folder to delete. |
public static boolean deleteFolder(File file)
//package com.java2s; /****************************************************************************** * Multiverse 2 Copyright (c) the Multiverse Team 2011. * * Multiverse 2 is licensed under the BSD License. * * For more information please check the README.md file included * * with this project. * ******************************************************************************/ import java.io.File; public class Main { /**// w w w. ja v a 2s. com * Used to delete a folder. * * @param file The folder to delete. * @return true if the folder was successfully deleted. */ public static boolean deleteFolder(File file) { if (file.exists()) { boolean ret = true; // If the file exists, and it has more than one file in it. if (file.isDirectory()) { for (File f : file.listFiles()) { ret = ret && deleteFolder(f); } } return ret && file.delete(); } else { return false; } } }