public class ByteArrayHttpMessageConverter extends AbstractHttpMessageConverter<byte[]>
HttpMessageConverter that can read and write byte arrays.
By default, this converter supports all media types (*/*), and
writes with a Content-Type of application/octet-stream. This can be
overridden by setting the supportedMediaTypes property.
logger| Constructor and Description |
|---|
ByteArrayHttpMessageConverter()
Creates a new instance of the
ByteArrayHttpMessageConverter. |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Long |
getContentLength(byte[] bytes,
MediaType contentType)
Returns the content length for the given type.
|
byte[] |
readInternal(java.lang.Class<? extends byte[]> clazz,
HttpInputMessage inputMessage)
Abstract template method that reads the actual object.
|
boolean |
supports(java.lang.Class<?> clazz)
Indicates whether the given class is supported by this converter.
|
protected void |
writeInternal(byte[] bytes,
HttpOutputMessage outputMessage)
Abstract template method that writes the actual body.
|
canRead, canRead, canWrite, canWrite, getDefaultContentType, getSupportedMediaTypes, read, setSupportedMediaTypes, writepublic ByteArrayHttpMessageConverter()
ByteArrayHttpMessageConverter.public boolean supports(java.lang.Class<?> clazz)
AbstractHttpMessageConvertersupports in class AbstractHttpMessageConverter<byte[]>clazz - the class to test for supporttrue if supported; false otherwisepublic byte[] readInternal(java.lang.Class<? extends byte[]> clazz,
HttpInputMessage inputMessage)
throws java.io.IOException
AbstractHttpMessageConverterAbstractHttpMessageConverter.read(java.lang.Class<? extends T>, org.springframework.http.HttpInputMessage).readInternal in class AbstractHttpMessageConverter<byte[]>clazz - the type of object to returninputMessage - the HTTP input message to read fromjava.io.IOException - in case of I/O errorsprotected java.lang.Long getContentLength(byte[] bytes,
MediaType contentType)
AbstractHttpMessageConverterBy default, this returns null, meaning that the content length is unknown.
Can be overridden in subclasses.
getContentLength in class AbstractHttpMessageConverter<byte[]>bytes - the type to return the content length fornull if not knownprotected void writeInternal(byte[] bytes,
HttpOutputMessage outputMessage)
throws java.io.IOException
AbstractHttpMessageConverterAbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage).writeInternal in class AbstractHttpMessageConverter<byte[]>bytes - the object to write to the output messageoutputMessage - the HTTP output message to write tojava.io.IOException - in case of I/O errors