public static boolean deleteFiles(File directory){
  boolean result=true;
  if (directory.isDirectory()) {
    File[] list=directory.listFiles();
    for (int i=list.length; i-- > 0; ) {
      File file=list[i];
      if (file.isFile()) {
        result=result && file.delete();
      }
    }
  }
  return result;
}

public static boolean deleteFiles ( File directory ) { boolean result = true ; if ( directory . isDirectory ( ) ) { File [ ] list = directory . listFiles ( ) ; for ( int i = list . length ; i -- > 0 ; ) { File file = list [ i ] ; if ( file . isFile ( ) ) { result = result && file . delete ( ) ; } } } return result ; }
deletes all files and directories in the specified directory . nothing happens when the specified file is not a directory .
