Java Recursive Delete recursiveDelete(final File root, final File file)

Here you can find the source of recursiveDelete(final File root, final File file)

Description

recursive Delete

License

BSD License

Declaration

private static void recursiveDelete(final File root, final File file) 

Method Source Code

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

import java.io.File;

public class Main {
    private static void recursiveDelete(final File root, final File file) {
        if (!file.isDirectory()) {
            file.delete();//  w  w  w.j av  a 2 s  .c o m
        } else {
            for (File next : file.listFiles()) {
                recursiveDelete(root, next);
            }
            if (!file.equals(root)) {
                // don't delete root directory
                file.delete();
            }
        }
    }

    public static void delete(final File file) {
        recursiveDelete(file, file);
    }
}

Related

  1. recursiveDelete(final File file, final boolean childrenOnly)
  2. recursiveDelete(final File fileOrDir)
  3. recursiveDelete(final File path)
  4. recursiveDelete(final File path, final boolean deleteParent)
  5. recursiveDelete(final File pFile)
  6. recursiveDelete(String fileName)
  7. recursiveDelete(String p_path, boolean p_deletemetoo)
  8. recursiveDelete(String path)
  9. recursiveDeleteFile(File f)