public static boolean tryToRenameTempFileToSaveFile(DownloadFileInfo downloadFileInfo){
  if (!DownloadFileUtil.isLegal(downloadFileInfo)) {
    return false;
  }
  if (isCompleted(downloadFileInfo)) {
    File saveFile=new File(downloadFileInfo.getFilePath());
    if (saveFile.exists() && saveFile.length() == downloadFileInfo.getDownloadedSizeLong() && saveFile.length() == downloadFileInfo.getFileSizeLong()) {
      return true;
    }
  }
 else {
    if (downloadFileInfo.getDownloadedSizeLong() == downloadFileInfo.getFileSizeLong()) {
      File tempFile=new File(downloadFileInfo.getTempFilePath());
      File saveFile=new File(downloadFileInfo.getFilePath());
      if (tempFile.exists() && tempFile.length() == downloadFileInfo.getDownloadedSizeLong() && !saveFile.exists()) {
        boolean isSucceed=tempFile.renameTo(saveFile);
        return isSucceed;
      }
    }
  }
  return false;
}

public static boolean tryToRenameTempFileToSaveFile ( DownloadFileInfo downloadFileInfo ) { if ( ! DownloadFileUtil . isLegal ( downloadFileInfo ) ) { return false ; } if ( isCompleted ( downloadFileInfo ) ) { File saveFile = new File ( downloadFileInfo . getFilePath ( ) ) ; if ( saveFile . exists ( ) && saveFile . length ( ) == downloadFileInfo . getDownloadedSizeLong ( ) && saveFile . length ( ) == downloadFileInfo . getFileSizeLong ( ) ) { return true ; } } else { if ( downloadFileInfo . getDownloadedSizeLong ( ) == downloadFileInfo . getFileSizeLong ( ) ) { File tempFile = new File ( downloadFileInfo . getTempFilePath ( ) ) ; File saveFile = new File ( downloadFileInfo . getFilePath ( ) ) ; if ( tempFile . exists ( ) && tempFile . length ( ) == downloadFileInfo . getDownloadedSizeLong ( ) && ! saveFile . exists ( ) ) { boolean isSucceed = tempFile . renameTo ( saveFile ) ; return isSucceed ; } } } return false ; }
try to rename temp file to save file
