Commit 5b4a61ad3035ce784c9926c7ca3d5195871439ab

Authored by 王彬
1 parent 09729c59
Exists in master

1.增加okhttp download file方法

build.gradle
... ... @@ -54,7 +54,7 @@ uploadArchives {
54 54 authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
55 55 }
56 56 pom.project {
57   - version '1.1.2'
  57 + version '1.1.3'
58 58 artifactId ARTIFACT_Id
59 59 groupId GROUP_ID
60 60 packaging TYPE
... ...
src/main/java/com/taover/util/UtilHttpByOkHttp.java
... ... @@ -73,6 +73,12 @@ public class UtilHttpByOkHttp {
73 73 return getHttpClient(url).newCall(request).execute().body().string();
74 74 }
75 75  
  76 + public static byte[] downloadFile(String url, final Map<String, String> headers) throws Exception{
  77 + Request request = getRequestBuilder(url, headers).get().build();
  78 +
  79 + return getHttpClient(url).newCall(request).execute().body().bytes();
  80 + }
  81 +
76 82 private static OkHttpClient getHttpClient(String url){
77 83 if(url.trim().toLowerCase().startsWith("https")){
78 84 return buildOkHttpClientForHttps();
... ...