标签:except url res 封装 第三方 request post请求 cut exception
一.原生OKHttp的Get和Post请求
1.OKHttp_GET 请求
private String get(String url) throws IOException { Request request = new Request.Builder() .url(url) .build(); Response response = client.newCall(request).execute(); return response.body().string(); }
2.OKHttp_POST 请求
private String post(String url, String json) throws IOException { RequestBody body = RequestBody.create(JSON, json); Request request = new Request.Builder() .url(url) .post(body) .build(); Response response = client.newCall(request).execute(); return response.body().string(); }
二.第三方封装好的OKHttp库-okhttp-utils
标签:except url res 封装 第三方 request post请求 cut exception
原文地址:http://www.cnblogs.com/ganchuanpu/p/6021412.html