Java File Path Delete deleteDir(File directory, boolean removeAll)

Here you can find the source of deleteDir(File directory, boolean removeAll)

Description

delete Dir

License

Open Source License

Declaration

public static void deleteDir(File directory, boolean removeAll) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * Copyright (c) 2010 Oracle/*from w  w  w  .  ja  v a2  s .  c o  m*/
 * 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
 *
 * Original file was copied from
 * org.eclipse.wst.common.project.facet.core.util.internal.FileUtil
 *
 ******************************************************************************/

import java.io.File;

public class Main {
    public static void deleteDir(File directory, boolean removeAll) {
        if (directory == null || !directory.isDirectory()) {
            return;
        }

        for (File file : directory.listFiles()) {
            if (file.isDirectory() && removeAll) {
                deleteDir(file, removeAll);
            } else {
                file.delete();
            }
        }

        directory.delete();
    }
}

Related

  1. deleteDir(File dir, String dirPath)
  2. deleteDir(File directory)
  3. deleteDir(File directory)
  4. deleteDir(File directory)
  5. deleteDir(File directory)
  6. deleteDir(File dirFile)
  7. deleteDir(File dirPath)
  8. deleteDir(File f)
  9. deleteDir(File f)