diff --git a/okhttp/src/main/java/okhttp3/ResponseBody.java b/okhttp/src/main/java/okhttp3/ResponseBody.java index acc383be27b0..c0d3309b310c 100644 --- a/okhttp/src/main/java/okhttp3/ResponseBody.java +++ b/okhttp/src/main/java/okhttp3/ResponseBody.java @@ -116,6 +116,13 @@ public final InputStream byteStream() { public abstract BufferedSource source(); + /** + * Returns the response as a byte array. + * + *
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 byte[] bytes() throws IOException { long contentLength = contentLength(); if (contentLength > Integer.MAX_VALUE) { @@ -148,7 +155,11 @@ public final Reader charStream() { /** * Returns the response as a string decoded with the charset of the Content-Type header. If that * header is either absent or lacks a charset, this will attempt to decode the response body as - * UTF-8. + * UTF-8. Closes {@link ResponseBody} automatically. + * + *
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 { return new String(bytes(), charset().name());