code: protected boolean cleanDirectory(File directory) {
          if (directory.isDirectory() && directory.listFiles().length != 0) {
              for (File file : directory.listFiles()) {
                  if (file.isFile()) {
                      file.delete();
                  }
              }
          }
          return directory.delete();
      }
docs: Delete all file of a directory and then delete this directory
  
  @param directory
  @return