public static void delete(File fileOrDirectory){
  if (!fileOrDirectory.exists()) {
    return;
  }
  if (fileOrDirectory.isDirectory()) {
    File[] filesList=fileOrDirectory.listFiles();
    for (    File child : filesList) {
      delete(child);
    }
  }
  final File to=new File(fileOrDirectory.getAbsolutePath() + System.currentTimeMillis());
  fileOrDirectory.renameTo(to);
  to.delete();
}

public static void delete ( File fileOrDirectory ) { if ( ! fileOrDirectory . exists ( ) ) { return ; } if ( fileOrDirectory . isDirectory ( ) ) { File [ ] filesList = fileOrDirectory . listFiles ( ) ; for ( File child : filesList ) { delete ( child ) ; } } final File to = new File ( fileOrDirectory . getAbsolutePath ( ) + System . currentTimeMillis ( ) ) ; fileOrDirectory . renameTo ( to ) ; to . delete ( ) ; }
delete file object . if it is a folder - it will be deleted recursively will all content .
