Java Delete Empty Directory deleteEmptyDirectory(File fileOrDirectory)

Here you can find the source of deleteEmptyDirectory(File fileOrDirectory)

Description

delete Empty Directory

License

Open Source License

Declaration

public static void deleteEmptyDirectory(File fileOrDirectory) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static void deleteEmptyDirectory(File fileOrDirectory) {
        if (fileOrDirectory.isDirectory()) {
            if (fileOrDirectory.list().length == 0) {
                //System.out.println("deleting " + fileOrDirectory.getName());
                fileOrDirectory.delete();
            }//from w ww .j a  v a 2 s .  c om
        }
    }
}

Related

  1. deleteEmptyChildren(java.io.File file)
  2. deleteEmptyDir(File directory)
  3. deleteEmptyDir(File file)
  4. deleteEmptyDirectories(List dirs)
  5. deleteEmptyDirectoryRecursive(File directory)
  6. deleteEmptyDirectoryRecursive(File directory)
  7. deleteEmptyDirs(File dir)
  8. deleteEmptyDirs(File dir)