OkHttp的返回值是Response, Response.body().string()会自动关闭流, 如果没有调用该方法, 需要手动关闭流: Response.body().close()
Response.body().string()源码, 使用了try语句关闭流
/**
* Returns the response as a string.
*
* <p>If the response starts with a <a href="https://en.wikipedia.org/wiki/Byte_order_mark">Byte
* Order Mark (BOM)</a>, it is consumed and used to determine the charset of the response bytes.
*
* <p>Otherwise if the response has a Content-Type header that specifies a charset, that is used
* to determine the charset of the response bytes.
*
* <p>Otherwise the response bytes are decoded as UTF-8.
*
* <p>This method loads entire response body into memory. If the response body is very large this
* may trigger an {@link OutOfMemoryError}. Prefer to stream the response body if this is a
* possibility for your response.
*/
public final String string() throws IOException {
try (BufferedSource source = source()) {
Charset charset = Util.bomAwareCharset(source, charset());
return source.readString(charset);
}
}