public static boolean deleteFiles(final File file){
  boolean ok=true;
  if (file != null) {
    if (file.isDirectory()) {
      final File[] files=file.listFiles();
      if (files != null) {
        for (        final File f : files) {
          if (f.isFile()) {
            ok&=f.delete();
          }
        }
      }
 else {
        ok=false;
      }
      ok&=file.delete();
    }
  }
  return ok;
}

public static boolean deleteFiles ( final File file ) { boolean ok = true ; if ( file != null ) { if ( file . isDirectory ( ) ) { final File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( final File f : files ) { if ( f . isFile ( ) ) { ok &= f . delete ( ) ; } } } else { ok = false ; } ok &= file . delete ( ) ; } } return ok ; }
utility function for deleting the files in a given directory and the directory itself . ( files only , non - recursive ) .
