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 Content
of
(byte[] bytes) Create a newContent
from the given input stream.static Content
of
(int size, IOSupplier<InputStream> supplier) Create a newContent
from the given input stream.static Content
Create a newContent
from the given file.static Content
Create a newContent
from the given UTF-8 string.int
size()
The size of the content in bytes.void
writeTo
(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 newContent
from the given UTF-8 string.- Parameters:
string
- the string to write- Returns:
- a new
Content
instance
-
of
Create a newContent
from the given input stream.- Parameters:
bytes
- the bytes to write- Returns:
- a new
Content
instance
-
of
Create a newContent
from the given file.- Parameters:
file
- the file to write- Returns:
- a new
Content
instance
-
of
Create a newContent
from 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
Content
instance
-