Java Delete File Recursively deleteR(File dir)

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

Description

delete R

License

Open Source License

Declaration

public static void deleteR(File dir) 

Method Source Code


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

import java.io.File;

public class Main {
    public static void deleteR(File dir) {
        deleteR(dir, true);//from w  ww . ja v a  2 s .co  m
    }

    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. deleteRec(File f)
  2. deleteRecursive(File dir)
  3. deleteRecursive(File dir)
  4. deleteRecursive(File dir)