Example usage for com.squareup.okhttp.internal Util UTF_8

List of usage examples for com.squareup.okhttp.internal Util UTF_8

Introduction

In this page you can find the example usage for com.squareup.okhttp.internal Util UTF_8.

Prototype

Charset UTF_8

To view the source code for com.squareup.okhttp.internal Util UTF_8.

Click Source Link

Document

A cheap and type-safe constant for the UTF-8 Charset.

Usage

From source file:com.kubeiwu.easyandroid.easyhttp.core.retrofit.GsonConverter.java

License:Apache License

public T fromBody(ResponseBody value, Request request) throws IOException {
    String string = value.string();
    System.out.println(":" + string);
    Reader reader = new InputStreamReader((new ByteArrayInputStream(string.getBytes(UTF8))), Util.UTF_8);
    try {/*w  w  w. j ava 2  s.c  o  m*/
        T t = typeAdapter.fromJson(reader);
        System.out.println("?" + t);
        String mimeType = value.contentType().toString();
        parseCache(request, t, string, mimeType);
        return t;
    } finally {
        closeQuietly(reader);
    }
}

From source file:retrofit.KGsonConverter.java

License:Apache License

public T fromBody(ResponseBody value, Request request) throws IOException {
    String string = value.string();
    Reader reader = new InputStreamReader((new ByteArrayInputStream(string.getBytes())), Util.UTF_8);
    try {//from  w w w. ja  va 2 s.  c  o  m
        T t = typeAdapter.fromJson(reader);
        if (t instanceof Result) {
            KResult kResult = (KResult) t;
            if (kResult != null && kResult.isSuccess()) {
                Entry entry = new Entry();

                entry.data = string.getBytes("UTF-8");
                entry.mimeType = value.contentType().toString();
                cache.put(request.urlString(), entry);
            }
        }
        return t;
    } finally {
        Utils.closeQuietly(reader);
    }
}