@Override
    public String downloadFromServer(RemoteUrl remoteUrl, String fileName, String localFileDir, String localFileDirTemp,
                                     String targetDirPath, boolean enableLocalDownloadDirInClassPath,
                                     int retryTimes, int retrySleepSeconds)
            throws Exception {

        // 目标地址文件
        File localFile = null;

        //
        // 进行下载、mv、copy
        //

        try {

            // 可重试的下载
            File tmpFilePathUniqueFile = retryDownload(localFileDirTemp, fileName, remoteUrl, retryTimes,
                    retrySleepSeconds);

            // 将 tmp file copy localFileDir
            localFile = transfer2SpecifyDir(tmpFilePathUniqueFile, localFileDir, fileName, false);

            // mv 到指定目录
            if (targetDirPath != null) {

                //
                if (enableLocalDownloadDirInClassPath || !targetDirPath.equals(ClassLoaderUtil.getClassPath
                        ())) {
                    localFile = transfer2SpecifyDir(tmpFilePathUniqueFile, targetDirPath, fileName, true);
                }
            }

            LOGGER.debug("Move to: " + localFile.getAbsolutePath());

        } catch (Exception e) {

            LOGGER.warn("download file failed, using previous download file.", e);
        }

        //
        // 判断是否下载失败
        //

        if (localFile == null || !localFile.exists()) {
            throw new Exception("target file cannot be found! " + fileName);
        }

        //
        // 下面为下载成功
        //

        // 返回相对路径
        String relativePathString = OsUtil.getRelativePath(localFile, new File(localFileDir));
        if (relativePathString != null) {
            if (new File(relativePathString).isFile()) {
                return relativePathString;
            }
        }

        // 否则, 返回全路径
        return localFile.getAbsolutePath();
    }
@ Override public String downloadFromServer ( RemoteUrl remoteUrl , String fileName , String localFileDir , String localFileDirTemp , String targetDirPath , boolean enableLocalDownloadDirInClassPath , int retryTimes , int retrySleepSeconds ) throws Exception { File localFile = null ; try { File tmpFilePathUniqueFile = retryDownload ( localFileDirTemp , fileName , remoteUrl , retryTimes , retrySleepSeconds ) ; localFile = transfer2SpecifyDir ( tmpFilePathUniqueFile , localFileDir , fileName , false ) ; if ( targetDirPath != null ) { if ( enableLocalDownloadDirInClassPath || ! targetDirPath . equals ( ClassLoaderUtil . getClassPath ( ) ) ) { localFile = transfer2SpecifyDir ( tmpFilePathUniqueFile , targetDirPath , fileName , true ) ; } } LOGGER . debug ( "Move to: " + localFile . getAbsolutePath ( ) ) ; } catch ( Exception e ) { LOGGER . warn ( "download file failed, using previous download file." , e ) ; } if ( localFile == null || ! localFile . exists ( ) ) { throw new Exception ( "target file cannot be found! " + fileName ) ; } String relativePathString = OsUtil . getRelativePath ( localFile , new File ( localFileDir ) ) ; if ( relativePathString != null ) { if ( new File ( relativePathString ) . isFile ( ) ) { return relativePathString ; } } return localFile . getAbsolutePath ( ) ; }
@param remoteUrl         远程地址
@param fileName          文件名
@param localFileDir      本地文件地址
@param targetDirPath     下载完后，配置文件指定的文件目录
@param retryTimes
@param retrySleepSeconds

@return

@throws Exception