Here you can find the source of delTree(File file)
Parameter | Description |
---|---|
file | start point for deletion -- not itself deleted |
public static void delTree(File file)
//package com.java2s; /*// w w w . java 2 s .c o m * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ import java.io.*; public class Main { /** Delete a directory tree recursively. * <p> * Does not delete file. * @param file start point for deletion -- not itself deleted */ public static void delTree(File file) { File[] files = file.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { delTree(files[i]); } } } files = file.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { files[i].delete(); } } } }