Java Utililty Methods Directory Clean

List of utility methods to do Directory Clean

Description

The list of methods to do Directory Clean are organized into topic(s).

Method

voidcleanDir(File dir)
Delete everything inside a directory.
if (Thread.interrupted()) {
    throw new InterruptedException();
if (!dir.exists()) {
    return;
for (File f : dir.listFiles()) {
    if (f.isDirectory()) {
...
voidcleanDir(File dir)
Cleans a directory, deleting all of its contents.
if (!dir.isDirectory()) {
    throw new IllegalStateException("Directory does not exist: " + dir);
for (File file : dir.listFiles()) {
    deleteFile(file);
voidcleanDir(File directory)
clean Dir
if (directory == null)
    return;
final File[] files = directory.listFiles();
if (files == null)
    return;
for (File file : files) {
    if (file.isDirectory()) {
        cleanDir(file);
...
booleancleanDir(final File dir)
clean Dir
boolean success = true;
if (dir.exists()) {
    success = recursiveDelete(dir) && success;
return dir.mkdirs() && success;
voidcleanDir(final File dir)
Cleans out the passed directory
if (dir == null)
    throw new IllegalArgumentException("The passed file was null");
if (dir.isFile())
    throw new IllegalArgumentException("The passed file [" + dir + "] was not a directory");
for (final File f : dir.listFiles()) {
    recursiveDel(f);
voidcleanDir(final File dir, final String exclude)
clean Dir
final String[] children = dir.list();
for (final String child : children) {
    if (child.equals(exclude)) {
        continue;
    final File file = new File(dir, child);
    if (file.isDirectory()) {
        delDir(file);
...
voidcleanDir(final String luceneDir)
clean Dir
if (luceneDir != null && luceneDir.length() > 0) {
    File directory = new File(luceneDir);
    File[] files = directory.listFiles();
    if (files != null) {
        for (File file : files) {
            if (file.isDirectory() && !(file.list().length == 0)) {
                cleanDir(file.getPath());
                file.delete();
...
booleancleanDir(String dir)
clean Dir
return deleteDir(new File(dir), false);
booleancleanDir(String directory)
Empty a directory without deleting it
String[] files = ls(directory);
boolean clean = true;
if (files != null) {
    for (String f : files) {
        String filename = directory + File.separator + f;
        File file = new File(filename);
        if (file.isDirectory())
            clean = cleanDir(filename) && file.delete();
...
voidcleanDir(String path)
clean Dir
File dir = new File(path);
if (dir.exists()) {
    if (!dir.isDirectory()) {
        throw new IOException("Path is not a directory: " + path);
    for (File file : dir.listFiles()) {
        file.delete();