Java Directory Delete emptyDirectory(File directory)

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

Description

empty Directory

License

Apache License

Declaration

public static boolean emptyDirectory(File directory) 

Method Source Code


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

import java.io.*;

public class Main {

    public static boolean emptyDirectory(File directory) {
        boolean result = true;
        File[] entries = directory.listFiles();
        for (int i = 0; i < entries.length; i++) {
            if (!entries[i].delete()) {
                result = false;//from   ww  w .  ja v a  2 s . c  o  m
            }
        }
        return result;
    }

    public static boolean emptyDirectory(String directoryName) {
        File dir = new File(directoryName);
        return emptyDirectory(dir);
    }
}

Related

  1. emptyDirectory(File dir)
  2. emptyDirectory(File dir)
  3. emptyDirectory(File dir)
  4. emptyDirectory(File dir)
  5. emptyDirectory(File directory)
  6. emptyDirectory(File path)
  7. emptyDirectory(final File directory)