Java Directory Clear clearDirectory(File dir)

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

Description

clear Directory

License

Open Source License

Declaration

public static void clearDirectory(File dir) 

Method Source Code

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

import java.io.File;

public class Main {
    public static void clearDirectory(File dir) {
        for (File f : dir.listFiles()) {
            delete(f);// w w  w .j  a  v a2  s . c o m
        }
    }

    public static void delete(File file) {
        if (file != null && file.exists()) {
            if (file.isDirectory()) {
                File[] files = file.listFiles();
                for (File f : files) {
                    delete(f);
                }
            }
            file.delete();
        }
    }
}

Related

  1. cleanDirectory(IProgressMonitor monitor, File directory, File base, int step)
  2. cleanDirectory(String dir)
  3. cleanDirectory(String dirPath)
  4. clearDirctory(File dir)
  5. clearDirectory(File dir)
  6. clearDirectory(File dir, boolean doTree)
  7. clearDirectory(File f)
  8. clearDirectory(File f)
  9. clearDirectory(File src)