Top Description Methods
org.springframework.core.serializer

public Interface Serializer<T>

Known Direct Implementers
org.springframework.core.serializer.support.SerializationDelegate, org.springframework.core.serializer.DefaultSerializer
Annotations
@FunctionalInterface
Type Parameters
<T>
the object type
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStream

A strategy interface for streaming an object to an OutputStream.
Authors
Gary Russell, Mark Fisher, Juergen Hoeller
Since
3.0.5
See Also
Deserializer

Method Summary

Modifier and TypeMethod and Description
public void
serialize(T
the object to serialize
object
,
OutputStream
the output stream
outputStream
)

Write an object of type T to the given OutputStream.

public default byte[]

Returns:

the resulting byte array
serializeToByteArray
(T
the object to serialize
object
)

Turn an object of type T into a serialized byte array.

Method Detail

serializeback to summary
public void serialize(T object, OutputStream outputStream) throws IOException

Write an object of type T to the given OutputStream.

Note

Implementations should not close the given OutputStream (or any decorators of that OutputStream) but rather leave this up to the caller.

Parameters
object:T

the object to serialize

outputStream:OutputStream

the output stream

Exceptions
IOException:
in case of errors writing to the stream
serializeToByteArrayback to summary
public default byte[] serializeToByteArray(T object) throws IOException

Turn an object of type T into a serialized byte array.

Parameters
object:T

the object to serialize

Returns:byte[]

the resulting byte array

Exceptions
IOException:
in case of serialization failure
Since
5.2.7