Java Delete File Recursively deleteRecursive(File file)

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

Description

delete Recursive

License

Apache License

Declaration

static void deleteRecursive(File file) 

Method Source Code

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

import java.io.File;

public class Main {
    static void deleteRecursive(File file) {
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            if (files != null) {
                for (File f : files) {
                    deleteRecursive(f);//from   www . j av  a2 s.c  om
                }
                if (!file.delete()) {
                    System.out.println("Could not delete folder " + file);
                }
            }
        } else {
            if (!file.delete()) {
                System.out.println("Could not delete file " + file);
            }
        }
    }
}

Related

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