Here you can find the source of deleteDirectory(File path)
Parameter | Description |
---|---|
path | The directory's path |
public static boolean deleteDirectory(File path)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 - 2013 by Timotei Dolean <timotei21@gmail.com> * /*from ww w .j av a 2 s. co m*/ * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ import java.io.File; public class Main { /** * Rercursively deletes a directory * * @param path * The directory's path * @return True if the delete was ok, false otherwise */ public static boolean deleteDirectory(File path) { if (path == null || !path.exists()) { return false; } if (!path.isDirectory()) { return path.delete(); } boolean res = true; for (File file : path.listFiles()) { res = res && deleteDirectory(file); } return res && path.delete(); } /** * Rercursively deletes a directory * * @param path * The directory's path * @return True if the delete was ok, false otherwise */ public static boolean deleteDirectory(String path) { return deleteDirectory(new File(path)); } }