接口 Serializer<T>
- 类型参数:
T
- the object type
- 所有已知实现类:
DefaultSerializer
,SerializationDelegate
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface Serializer<T>
A strategy interface for streaming an object to an OutputStream.- 从以下版本开始:
- 3.0.5
- 作者:
- Gary Russell, Mark Fisher, Juergen Hoeller
- 另请参阅:
Deserializer
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 void
serialize(T object, OutputStream outputStream)
Write an object of type T to the given OutputStream.default byte[]
serializeToByteArray(T object)
Turn an object of type T into a serialized byte array.
方法详细资料
serialize
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.
- 参数:
object
- the object to serializeoutputStream
- the output stream- 抛出:
IOException
- in case of errors writing to the stream
serializeToByteArray
default byte[] serializeToByteArray(T object) throws IOException
Turn an object of type T into a serialized byte array.- 参数:
object
- the object to serialize- 返回:
- the resulting byte array
- 抛出:
IOException
- in case of serialization failure- 从以下版本开始:
- 5.2.7