public interface TypedData
Modifier and Type | Method and Description |
---|---|
ByteBuf |
getBuffer()
The raw data as a (unmodifiable) buffer.
|
byte[] |
getBytes()
The raw data as bytes.
|
MediaType |
getContentType()
The type of the data.
|
InputStream |
getInputStream()
An input stream of the data.
|
String |
getText()
The data as text.
|
String |
getText(Charset charset) |
void |
writeTo(OutputStream outputStream)
Writes the data to the given output stream.
|
MediaType getContentType()
String getText()
If a content type was provided, and it provided a charset parameter, that charset will be used to decode the text.
If no charset was provided, UTF-8
will be assumed.
This can lead to incorrect results for non text/*
type content types.
For example, application/json
is implicitly UTF-8
but this method will not know that.
byte[] getBytes()
ByteBuf getBuffer()
void writeTo(OutputStream outputStream) throws IOException
This method does not flush or close the stream.
outputStream
- The stream to write toIOException
- any thrown when writing to the output streamInputStream getInputStream()