Android File Delete 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://from  w w  w  . ja  v  a 2s .c  om
 *     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. deleteFolder(File targetFolder)
  2. deleteFolders(File dir)
  3. deleteIfExists(File file)
  4. deleteOldFile(String strPath, String strWildcard, int iOffset)
  5. deleteRecursively(File dir)
  6. deleteSubfiles(String publishTemppath)
  7. deleteTempDir(File dir)
  8. deleteTempFile(File tmpFile)
  9. deleteTempFiles()