Java Folder Delete clearDir(File dir)

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

Description

clear Dir

License

Apache License

Declaration

public static boolean clearDir(File dir) 

Method Source Code


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

import java.io.File;

public class Main {
    public static boolean clearDir(File dir) {
        if (!dir.exists()) {
            return false;
        }//from   w  w  w.j ava 2 s.  c o  m

        for (File file : dir.listFiles()) {
            if (file.isDirectory()) {
                clearDir(file);
            }
            if (!file.delete())
                return false;
        }
        return true;
    }
}

Related

  1. clearDir(File d)
  2. clearDir(File dir)
  3. clearDir(File dir)
  4. clearDir(File dir)
  5. clearFiles(File dir)