public static boolean deleteRecursive(File path) throws FileNotFoundException {
  if (!path.exists())   throw new FileNotFoundException(path.getAbsolutePath());
  boolean ret=true;
  if (path.isDirectory()) {
    for (    File f : path.listFiles()) {
      ret=ret && Utils.deleteRecursive(f);
    }
  }
  return ret && path.delete();
}

public static boolean deleteRecursive ( File path ) throws FileNotFoundException { if ( ! path . exists ( ) ) throw new FileNotFoundException ( path . getAbsolutePath ( ) ) ; boolean ret = true ; if ( path . isDirectory ( ) ) { for ( File f : path . listFiles ( ) ) { ret = ret && Utils . deleteRecursive ( f ) ; } } return ret && path . delete ( ) ; }
by default file # delete fails for non - empty directories , it works like " rm " . we need something a little more brutual - this does the equivalent of " rm - r "
