Java Delete File Recursively deleteRecursively(File f)

Here you can find the source of deleteRecursively(File f)

Description

delete Recursively

License

Open Source License

Declaration

private static void deleteRecursively(File f) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * All rights reserved. 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
 *
 * Contributors:/*  w w w  . j  av a 2  s  .c o m*/
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.io.File;

import java.io.IOException;

public class Main {
    private static void deleteRecursively(File f) throws IOException {
        if (f.isDirectory()) {
            for (String s : f.list()) {
                deleteRecursively(new File(f, s));
            }
        }

        boolean b = f.delete();
        if (!b) {
            throw new IOException("failed to delete " + f);
        }
    }
}

Related

  1. deleteRecursiveDirectory(String dirName)
  2. deleteRecursiveFileDir(File dir)
  3. deleteRecursively(File dir)
  4. deleteRecursively(File directory)
  5. deleteRecursively(File dirEntry)
  6. deleteRecursively(File f)
  7. deleteRecursively(File file)
  8. deleteRecursively(File file)
  9. deleteRecursively(File file)