我请求链接以获取 JSON,但 response.body().string() 值始终有错误。另一种方法是,我将response.body().string()拆分为response.body()和字符串,但Android studio找不到ResponseBody。2路不行。请帮忙!
String doGetRequest(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
//ResponseBody responseBody = response.body();
//String content = responseBody.string();
//System.out.println(content);
return response.body().string();
}
}
明月笑刀无情
当年话下
胡子哥哥
相关分类