当前位置: 首页>>代码示例>>Java>>正文


Java ResponseBody.close方法代码示例

本文整理汇总了Java中com.squareup.okhttp.ResponseBody.close方法的典型用法代码示例。如果您正苦于以下问题:Java ResponseBody.close方法的具体用法?Java ResponseBody.close怎么用?Java ResponseBody.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.squareup.okhttp.ResponseBody的用法示例。


在下文中一共展示了ResponseBody.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
/**
 *
 * @param params
 * @return
 */
@Override
protected String doInBackground(Void... params) {
    OkHttpClient client = new OkHttpClient();

    HttpUrl httpUrl = HttpUrl.parse(COIN_DESK_API_URL);
    //System.out.println("Requesting : " + httpUrl.toString());

    FormEncodingBuilder formBody = new FormEncodingBuilder();
    formBody.add("lastHours", "24");
    formBody.add("maxRespArrSize", "24");

    Request request = new Request.Builder()
            .url(httpUrl)
            .post(formBody.build())
            .build();

    String content = null;
    try {
        Response response = client.newCall(request).execute();
        ResponseBody body = response.body();

        if (isZipped(response)) {
            content = unzip(body);
        } else {
            content = body.string();
        }

        body.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return content;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:40,代码来源:CexChartAPI.java

示例2: fromResponseBody

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
@Override
public Converter<ResponseBody, ?> fromResponseBody(Type type, Annotation[] annotations) {
    //noinspection EqualsBetweenInconvertibleTypes
    if (Document.class.equals(type)) {
        return new Converter<ResponseBody, Object>() {

            @Override
            public Object convert(ResponseBody responseBody) throws IOException {
                Document doc = Jsoup.parse(responseBody.string());
                responseBody.close();
                return doc;
            }
        };
    }

    return null;
}
 
开发者ID:y3seker,项目名称:EgeYemekhaneMobil,代码行数:18,代码来源:DocumentConverterFactory.java

示例3: doInBackground

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
/**
 *
 * @param params
 * @return
 */
@Override
protected String doInBackground(Void... params) {

    OkHttpClient client = new OkHttpClient();

    HttpUrl httpUrl = HttpUrl.parse(TwitterSearchURL);
    httpUrl = httpUrl.newBuilder()
            .addQueryParameter("q", _searchTerm)
            .addQueryParameter("lang", "en")
            .addQueryParameter("result_type", "recent")
            .build();

    Request request = new Request.Builder()
            .url(httpUrl)
            .addHeader("Authorization", "Bearer " + _bearerToken)
            .addHeader("Accept-Encoding", "gzip")
            .build();

    String content = null;
    try {
        Response response = client.newCall(request).execute();
        ResponseBody body = response.body();

        if (isZipped(response)) {
            content = unzip(body);
        } else {
            content = body.string();
        }

        body.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return content;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:42,代码来源:TwitterSearchApi.java

示例4: onMessage

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
@Override
public void onMessage(ResponseBody body) throws IOException {
    if (body.contentType() == TEXT) {
        listener.textMessage(body.charStream());
    } else if (body.contentType() == BINARY) {
        listener.bytesMessage(body.byteStream());
    }
    body.close();
}
 
开发者ID:membrane,项目名称:kubernetes-client,代码行数:10,代码来源:WebSockets.java


注:本文中的com.squareup.okhttp.ResponseBody.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。