Interface Content
- All Known Implementing Classes:
InspectedContent,Layer
public interface Content
Content with a known size that can be written to an
OutputStream.- Since:
- 2.3.0
- Author:
- Phillip Webb
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Method Details
-
size
int size()The size of the content in bytes.- Returns:
- the content size
-
writeTo
Write the content to the given output stream.- Parameters:
outputStream- the output stream to write to- Throws:
IOException- on IO error
-
of
Create a newContentfrom the given UTF-8 string.- Parameters:
string- the string to write- Returns:
- a new
Contentinstance
-
of
Create a newContentfrom the given input stream.- Parameters:
bytes- the bytes to write- Returns:
- a new
Contentinstance
-
of
Create a newContentfrom the given file.- Parameters:
file- the file to write- Returns:
- a new
Contentinstance
-
of
Create a newContentfrom the given input stream. The stream will be closed after it has been written.- Parameters:
size- the size of the supplied input streamsupplier- the input stream supplier- Returns:
- a new
Contentinstance
-