Java File Path Delete deleteAll(File path)

Here you can find the source of deleteAll(File path)

Description

delete All

License

Open Source License

Declaration

public static void deleteAll(File path) 

Method Source Code

//package com.java2s;
/******************************************************************************* 
 * Copyright (c) 2008 Red Hat, Inc. /*from  ww  w .j  av a  2s . c  om*/
 * Distributed under license by Red Hat, Inc. All rights reserved. 
 * This program is 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 
 * 
 * Contributors: 
 * Red Hat, Inc. - initial API and implementation 
 ******************************************************************************/

import java.io.File;

public class Main {
    public static void deleteAll(File path) {
        if (!path.exists())
            return;
        if (path.isFile()) {
            path.delete();
            return;
        }
        File[] files = path.listFiles();
        for (int i = 0; i < files.length; i++) {
            deleteAll(files[i]);
        }
        path.delete();
    }
}

Related

  1. delete(String path)
  2. delete(String path)
  3. delete(String path)
  4. deleteAll(File path)
  5. deleteAll(File path)
  6. deleteAllFile(final File dir)
  7. deleteAllFile(String directory)
  8. deleteAllFile(String folderPath)
  9. deleteAllFile(String path)