public static int rcDelete(File dir){
  int count=0;
  if (dir.isDirectory()) {
    File[] files=dir.listFiles();
    for (    File f : files)     count+=rcDelete(f);
  }
  count+=dir.delete() ? 1 : 0;
  return count;
}

public static int rcDelete ( File dir ) { int count = 0 ; if ( dir . isDirectory ( ) ) { File [ ] files = dir . listFiles ( ) ; for ( File f : files ) count += rcDelete ( f ) ; } count += dir . delete ( ) ? 1 : 0 ; return count ; }
recursively deletes an entire local file system directory and returns the number of files deleted .
