Here you can find the source of deleteRecursively(File dir)
Parameter | Description |
---|---|
dir | a parameter |
public static boolean deleteRecursively(File dir)
//package com.java2s; /**//from w ww .j a va 2 s.c o m * Aptana Studio * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ import java.io.File; public class Main { /** * Deletes a file recursively. If it's a directory we delete depth first, then delete the directory. The result is * true only if the directory and all it's children are deleted. * * @param dir * @return */ public static boolean deleteRecursively(File dir) { if (dir == null) { return false; } boolean result = true; if (dir.isDirectory()) { for (File child : dir.listFiles()) { result = result && deleteRecursively(child); } } return result && dir.delete(); } }