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.IOException
public final InputStream byteStream() throws IOException
IOException
public abstract okio.BufferedSource source() throws IOException
IOException
public final byte[] bytes() throws IOException
IOException
public final Reader charStream() throws IOException
IOException
public final String string() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public 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.