Commit 5b4a61ad3035ce784c9926c7ca3d5195871439ab
1 parent
09729c59
Exists in
master
1.增加okhttp download file方法
Showing
2 changed files
with
7 additions
and
1 deletions
Show diff stats
build.gradle
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(); | ... | ... |