Java Directory Clear clearDirctory(File dir)

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

Description

clear Dirctory

License

Open Source License

Declaration

public static void clearDirctory(File dir) 

Method Source Code


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

import java.io.File;

public class Main {
    public static void clearDirctory(File dir) {
        deleteR(dir, false);/*from   w  w w. jav  a 2 s . co  m*/
    }

    public static void deleteR(File dir) {
        deleteR(dir, true);
    }

    private static void deleteR(File file, boolean deleteRoot) {

        File[] listFiles = file.listFiles();

        if (listFiles != null) {
            for (File child : listFiles) {
                deleteR(child, true);
            }
        }

        if (deleteRoot) {
            file.delete();
        }
    }
}

Related

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