Java Directory Delete emptyDirectory(File dir)

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

Description

empty Directory

License

Apache License

Parameter

Parameter Description
dir a parameter

Declaration

public static void emptyDirectory(File dir) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**//w  ww.  j a v a  2s  .  c o m
     * @param dir
     */
    public static void emptyDirectory(File dir) {
        if (dir.exists() && dir.isDirectory()) {
            File[] tmpFiles = dir.listFiles();

            if (tmpFiles.length > 0) {
                for (File f : tmpFiles) {
                    f.delete();
                }
            }
        }
    }
}

Related

  1. emptyDir(String dirName)
  2. emptyDir(String path)
  3. emptyDirectory(File dir)
  4. emptyDirectory(File dir)
  5. emptyDirectory(File dir)
  6. emptyDirectory(File directory)
  7. emptyDirectory(File directory)
  8. emptyDirectory(File path)
  9. emptyDirectory(final File directory)