public abstract class ResponseBody
extends java.lang.Object
implements java.io.Closeable
| 构造器和说明 |
|---|
ResponseBody() |
| 限定符和类型 | 方法和说明 |
|---|---|
byte[] |
bytes() |
java.io.InputStream |
byteStream() |
java.io.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,
BufferedSource content)
Returns a new response body that transmits
content. |
static ResponseBody |
create(MediaType contentType,
java.lang.String content)
Returns a new response body that transmits
content. |
abstract BufferedSource |
source() |
java.lang.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()
bytes(), or byteStream(), or
-1 if unknown.public final java.io.InputStream byteStream()
public abstract BufferedSource source()
public final byte[] bytes()
throws java.io.IOException
java.io.IOExceptionpublic final java.io.Reader charStream()
public final java.lang.String string()
throws java.io.IOException
java.io.IOExceptionpublic void close()
close 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseablepublic static ResponseBody create(MediaType contentType, java.lang.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, BufferedSource content)
content.