|
@@ -1,6 +1,7 @@
|
|
|
package com.fdkankan.common.util;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import okhttp3.*;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
@@ -298,18 +299,21 @@ public class OkHttpUtils {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- //test
|
|
|
- public static void main(String[] args) {
|
|
|
-// String url = "http://192.168.0.30:8000/pro";
|
|
|
-// JSONObject jsonObject = new JSONObject();
|
|
|
-// jsonObject.put("name", "vr-t-2KZ4MQv-001");
|
|
|
-// jsonObject.put("map", "t-2KZ4MQv");
|
|
|
-// jsonObject.put("resolution", 1024);
|
|
|
-// int num[] = new int[1];
|
|
|
-// num[0] = -1;
|
|
|
-// jsonObject.put("ids", num);
|
|
|
-// System.out.println(httpPostJson(url, jsonObject.toJSONString()));
|
|
|
- System.out.println(httpGet("http://192.168.0.165:8000/check"));
|
|
|
+ public static long downloadFile(String url, String dest,int retryTimes){
|
|
|
+ for (int i = 0; i <= retryTimes; i++) {
|
|
|
+ try {
|
|
|
+ return HttpUtil.downloadFile(url, dest);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(String.format("文件第%d次下载失败", i + 1), e);
|
|
|
+ try {
|
|
|
+ Thread.sleep(3000);
|
|
|
+ } catch (InterruptedException interruptedException) {
|
|
|
+ interruptedException.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0L;
|
|
|
}
|
|
|
|
|
|
}
|