Java Delete File Recursively deleteRecursive(File file)

Here you can find the source of deleteRecursive(File file)

Description

delete Recursive

License

Open Source License

Declaration

public static void deleteRecursive(File file) 

Method Source Code


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

import java.io.File;

public class Main {
    public static void deleteRecursive(File file) {
        if (file.exists()) {
            if (file.isDirectory()) {
                for (File f : file.listFiles()) {
                    deleteRecursive(f);//from   w ww .  ja v a  2  s.com
                }
            }
            boolean deleted = file.delete();
            if (deleted)
                System.out.println("      deleted " + file.getAbsolutePath());
            else
                System.out.println("  NOT deleted " + file.getAbsolutePath());
        }
    }
}

Related

  1. deleteRecursive(File dir)
  2. deleteRecursive(File f)
  3. deleteRecursive(File f)
  4. deleteRecursive(File f)
  5. deleteRecursive(File f)
  6. deleteRecursive(File file)
  7. deleteRecursive(File file)
  8. deleteRecursive(File file)
  9. deleteRecursive(File file)