Java Code Examples for com.squareup.okhttp.ResponseBody#string()
The following examples show how to use
com.squareup.okhttp.ResponseBody#string() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NameFetcher.java From RedisBungee with Eclipse Public License 1.0 | 6 votes |
public static List<String> nameHistoryFromUuid(UUID uuid) throws IOException { String url = "https://api.mojang.com/user/profiles/" + uuid.toString().replace("-", "") + "/names"; Request request = new Request.Builder().url(url).get().build(); ResponseBody body = httpClient.newCall(request).execute().body(); String response = body.string(); body.close(); Type listType = new TypeToken<List<Name>>() { }.getType(); List<Name> names = RedisBungee.getGson().fromJson(response, listType); List<String> humanNames = new ArrayList<>(); for (Name name : names) { humanNames.add(name.name); } return humanNames; }
Example 2
Source File: ApiResponseBodyConverter.java From NewsMe with Apache License 2.0 | 5 votes |
@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 { } }
Example 3
Source File: ToStringConverterFactory.java From materialup with Apache License 2.0 | 5 votes |
@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; }
Example 4
Source File: HttpApiBase.java From iview-android-tv with MIT License | 5 votes |
private String extractBody(ResponseBody body) { if (body != null) { try { return body.string(); } catch (IOException e) { e.printStackTrace(); } } return null; }
Example 5
Source File: ToStringConverter.java From WeGit with Apache License 2.0 | 5 votes |
@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; }