Java Directory Delete emptyDir(File directory)

Here you can find the source of emptyDir(File directory)

Description

empty Dir

License

Open Source License

Declaration

public static void emptyDir(File directory) 

Method Source Code

//package com.java2s;
/*/* w  ww .jav  a2 s.  c o m*/
 * Copyright (c) 2013, 2014 Chris Newland.
 * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
 * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
 */

import java.io.File;

public class Main {
    public static void emptyDir(File directory) {
        if (directory.exists() && directory.isDirectory()) {
            File[] contents = directory.listFiles();

            for (File file : contents) {
                if (file.isDirectory()) {
                    emptyDir(file);
                    file.delete();
                } else {
                    file.delete();
                }
            }
        }
    }
}

Related

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