Java Directory Delete emptyDirectory(final File directory)

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

Description

empty Directory

License

BSD License

Declaration

public static void emptyDirectory(final File directory) throws IOException 

Method Source Code

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

import java.io.File;
import java.io.IOException;

public class Main {
    public static void emptyDirectory(final File directory) throws IOException {
        for (final File file : directory.listFiles()) {
            if (file.isDirectory()) {
                emptyDirectory(file);/*from w  w  w  .  j  av a2  s.c  om*/
            }

            if (!file.delete()) {
                throw new IOException("Can't delete " + file);
            }
        }
    }
}

Related

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