Java Delete Empty Directory deleteEmptyDirs(File dir)

Here you can find the source of deleteEmptyDirs(File dir)

Description

delete Empty Dirs

License

Open Source License

Declaration

public static void deleteEmptyDirs(File dir) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2007, 2010 IBM Corporation and others.
 *  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
 * //from w ww .  j  a v  a  2s  . c om
 *  Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.io.*;

public class Main {
    public static void deleteEmptyDirs(File dir) throws IOException {
        File[] files = dir.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i += 1) {
                deleteEmptyDirs(files[i]);
            }
            dir.getCanonicalFile().delete();
        }
    }
}

Related

  1. deleteEmptyDirectories(List dirs)
  2. deleteEmptyDirectory(File fileOrDirectory)
  3. deleteEmptyDirectoryRecursive(File directory)
  4. deleteEmptyDirectoryRecursive(File directory)
  5. deleteEmptyDirs(File dir)
  6. deleteEmptyFiles(String p)
  7. deleteEmptyFolders(java.io.File file)
  8. deleteEmptyFolders(String[] args)
  9. deleteEmptyParentFolders(File leafFolder)