FileDocCategorySizeDatePackage
FileUtils.javaAPI DocApache Lucene 2.1.01730Wed Feb 14 10:46:14 GMT 2007org.apache.lucene.benchmark.byTask.utils

FileUtils

public class FileUtils extends Object
File utilities.

Fields Summary
Constructors Summary
Methods Summary
public static booleanfullyDelete(java.io.File dir)
Delete files and directories, even if non-empty.

param
dir file or directory
return
true on success, false if no or part of files have been deleted
throws
java.io.IOException

    if (dir == null || !dir.exists()) return false;
    File contents[] = dir.listFiles();
    if (contents != null) {
      for (int i = 0; i < contents.length; i++) {
        if (contents[i].isFile()) {
          if (!contents[i].delete()) {
            return false;
          }
        } else {
          if (!fullyDelete(contents[i])) {
            return false;
          }
        }
      }
    }
    return dir.delete();