public abstract class ResponseBody extends Object implements Closeable
| Constructor and Description |
|---|
ResponseBody() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
bytes() |
InputStream |
byteStream() |
Reader |
charStream()
Returns the response as a character stream decoded with the charset
of the Content-Type header.
|
void |
close() |
abstract long |
contentLength()
Returns the number of bytes in that will returned by
bytes(), or
byteStream(), or -1 if unknown. |
abstract MediaType |
contentType() |
static ResponseBody |
create(MediaType contentType,
byte[] content)
Returns a new response body that transmits
content. |
static ResponseBody |
create(MediaType contentType,
long contentLength,
okio.BufferedSource content)
Returns a new response body that transmits
content. |
static ResponseBody |
create(MediaType contentType,
String content)
Returns a new response body that transmits
content. |
abstract okio.BufferedSource |
source() |
String |
string()
Returns the response as a string decoded with the charset of the
Content-Type header.
|
public abstract MediaType contentType()
public abstract long contentLength()
throws IOException
bytes(), or
byteStream(), or -1 if unknown.IOExceptionpublic final InputStream byteStream() throws IOException
IOExceptionpublic abstract okio.BufferedSource source()
throws IOException
IOExceptionpublic final byte[] bytes()
throws IOException
IOExceptionpublic final Reader charStream() throws IOException
IOExceptionpublic final String string() throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic static ResponseBody create(MediaType contentType, String content)
content. If contentType is non-null and lacks a charset, this will use UTF-8.public static ResponseBody create(MediaType contentType, byte[] content)
content.public static ResponseBody create(MediaType contentType, long contentLength, okio.BufferedSource content)
content.Copyright © 2016. All Rights Reserved.