目录

ResponseBody

Class Info

public abstract class ResponseBody implements Closeable

响应体数据。

Public Field Summary

Qualifier and Type

Field and Description

public Charset

charSet

使用的编码字符集。

public Reader

reader

输入流。

Public Method Summary

Qualifier and Type

Method Name and Description

public final byte[]

bytes()

将输入流转为字节数组。

public final Reader

charStream()

将输入流转化为Reader对象,方便读写。

public abstract void

close()

关闭响应体的数据流对象。

public abstract long

getContentLength()

获取响应数据的长度。

public abstract String

getContentType()

获取响应数据的类型。

public abstract InputStream

getInputStream()

获取服务器响应体的数据流。

Public Fields

[h2]charSet

Field

public Charset charSet

使用的编码字符集。

[h2]reader

Field

public Reader reader

输入流。

Public Methods

[h2]bytes

Method

public final byte[] bytes() throws IOException

将输入流转为字节数组。

Returns

Type

Description

byte[]

使用输入流转换成的字节数组。

Throws

Name

Description

IOException

如果在此过程中发生IOException将抛出异常。

[h2]charStream

Method

public final Reader charStream()

将输入流转化为Reader对象,方便读写。当获取到的输入流为null,则返回null。

Returns

Type

Description

Reader

使用输入流转成的Reader对象。

[h2]close

Method

public abstract void close() throws IOException

关闭响应体的数据流对象。

Throws

Name

Description

IOException

如果在此过程中发生IOException将抛出异常。

[h2]getContentLength

Method

public abstract long getContentLength()

获取响应数据的长度。

Returns

Type

Description

long

响应数据的长度。

[h2]getContentType

Method

public abstract String getContentType()

获取响应数据的类型。

Returns

Type

Description

String

响应数据的类型。

[h2]getInputStream

Method

public abstract InputStream getInputStream()

获取服务器响应体的数据流。

Returns

Type

Description

InputStream

服务器响应体的数据流。