接口 Content
- 所有已知实现类:
InspectedContent,Layer
public interface Content
Content with a known size that can be written to an
OutputStream.- 从以下版本开始:
- 2.3.0
- 作者:
- Phillip Webb
-
方法概要
修饰符和类型方法说明static Contentof(byte[] bytes) Create a newContentfrom the given input stream.static Contentof(int size, IOSupplier<InputStream> supplier) Create a newContentfrom the given input stream.static ContentCreate a newContentfrom the given file.static ContentCreate a newContentfrom the given UTF-8 string.intsize()The size of the content in bytes.voidwriteTo(OutputStream outputStream) Write the content to the given output stream.
-
方法详细资料
-
size
int size()The size of the content in bytes.- 返回:
- the content size
-
writeTo
Write the content to the given output stream.- 参数:
outputStream- the output stream to write to- 抛出:
IOException- on IO error
-
of
Create a newContentfrom the given UTF-8 string.- 参数:
string- the string to write- 返回:
- a new
Contentinstance
-
of
Create a newContentfrom the given input stream.- 参数:
bytes- the bytes to write- 返回:
- a new
Contentinstance
-
of
Create a newContentfrom the given file.- 参数:
file- the file to write- 返回:
- a new
Contentinstance
-
of
Create a newContentfrom the given input stream. The stream will be closed after it has been written.- 参数:
size- the size of the supplied input streamsupplier- the input stream supplier- 返回:
- a new
Contentinstance
-