网络数据请求

自己用

String url = "";
Request.Builder builder_ = new Request.Builder()
        .url(url)
        .cacheControl(CacheControl.FORCE_NETWORK)
        .get();
Response response_ = null;
try {
        response_ = HttpUtils.getOkHttpClient().newCall(builder_.build()).execute();
        ResponseBody body = response_.body();
        if (body != null) {
            String data = body.string();
	    System.out.println("===data=" + data);
        }
} catch (Exception e) {
        System.out.println("===error=" + e.getMessage());
}
posted @ 2020-01-15 17:48  sky-walker  阅读(105)  评论(0编辑  收藏  举报