Java Delete File Recursively deleteRecursively(File fileEntry)

Here you can find the source of deleteRecursively(File fileEntry)

Description

Recursively deletes a directory or a file immediately.

License

LGPL

Parameter

Parameter Description
fileEntry is the entry to begin with

Declaration

private static void deleteRecursively(File fileEntry) 

Method Source Code


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

import java.io.File;

public class Main {
    /**/*from  w ww.  ja  v a 2s  .  c o m*/
     * Recursively deletes a directory or a file immediately.
     *
     * @param fileEntry
     *            is the entry to begin with
     */
    private static void deleteRecursively(File fileEntry) {
        if (fileEntry.isDirectory()) {
            File[] listFiles = fileEntry.listFiles();
            for (File file : listFiles) {
                deleteRecursively(file);
            }
        }
        if (!fileEntry.delete()) {
            fileEntry.deleteOnExit();
        }

    }
}

Related

  1. deleteRecursively(File file)
  2. deleteRecursively(File file)
  3. deleteRecursively(File file)
  4. deleteRecursively(File file)
  5. deleteRecursively(File file)
  6. deleteRecursively(File fileOrDir)
  7. deleteRecursively(File fileOrDir)
  8. deleteRecursively(File fileToDelete)
  9. deleteRecursively(File fRoot)