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


Java ResponseBody.string方法代码示例

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


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

示例3: convert

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
@Override public T convert(ResponseBody value) throws IOException {
    String str = value.string();
    try {
        int start = str.indexOf("\"pagebean\":") + "\"pagebean\":".length();
        int end = str.indexOf(",\"ret_code\"");
        return gson.fromJson(str.substring(start, end), type);
    } finally {
    }
}
 
开发者ID:iQuick,项目名称:NewsMe,代码行数:10,代码来源:ApiResponseBodyConverter.java

示例4: fromResponseBody

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
@Override
public Converter<ResponseBody, ?> fromResponseBody(Type type, Annotation[] annotations) {
    if (String.class.equals(type)) {
        return new Converter<ResponseBody, String>() {
            @Override
            public String convert(ResponseBody value) throws IOException {
                return value.string();
            }
        };
    }
    return null;
}
 
开发者ID:goodev,项目名称:materialup,代码行数:13,代码来源:ToStringConverterFactory.java

示例5: fromResponseBody

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
@Override
public Converter<ResponseBody, ?> fromResponseBody(Type type, Annotation[] annotations) {
    if (String.class.equals(type)) {
        return new Converter<ResponseBody, String>() {
            @Override public String convert(ResponseBody value) throws IOException {
                return value.string();
            }
        };
    }
    return null;
}
 
开发者ID:xcjs,项目名称:fetlife-oss,代码行数:12,代码来源:ToStringConverterFactory.java

示例6: extractBody

import com.squareup.okhttp.ResponseBody; //导入方法依赖的package包/类
private String extractBody(ResponseBody body) {
    if (body != null) {
        try {
            return body.string();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return null;
}
 
开发者ID:nextux,项目名称:sbs-android-tv,代码行数:11,代码来源:HttpApiBase.java


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