public final class ObjectCodec extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ObjectCodec.DecodingException
Thrown on deserialization error.
|
static class |
ObjectCodec.EncodingException
Thrown on serialization error.
|
| Modifier and Type | Method and Description |
|---|---|
static Serializable |
decode(byte[] bytes)
Deserializes the given array of
bytes into an object. |
static <T extends Serializable> |
decode(byte[] bytes,
Class<T> t)
Deserializes the given array of
bytes into an object. |
static byte[] |
encode(Serializable object)
Serializes the given
Serializable object into an array of
bytes. |
public static byte[] encode(Serializable object)
Serializable object into an array of
bytes.object - the object to encode.NullPointerException - if object is null.ObjectCodec.EncodingException - if the given object cannot be serialized.public static Serializable decode(byte[] bytes)
bytes into an object.bytes - the object's encoding.NullPointerException - if bytes is null.ObjectCodec.DecodingException - if the deserialization fails.public static <T extends Serializable> T decode(byte[] bytes, Class<T> t)
bytes into an object.T - the object's expected type.bytes - the object's encoding.t - the object's expected type's Class.NullPointerException - if one of the arguments is null.ObjectCodec.DecodingException - if the deserialization fails.ClassCastException - if the deserialized object is not an
instance of the expected class.Copyright © 2012–2015. All rights reserved.