public class SerializeUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
deserialize(byte[] objectData)
Deserializes a single
Object from an array of bytes. |
static byte[] |
serialize(Serializable obj,
int compressThreshold)
Serializes an
Object to a byte array for
storage/serialization. |
public static byte[] serialize(Serializable obj, int compressThreshold)
Serializes an Object to a byte array for
storage/serialization.
obj - the object to serialize to bytesSerializationException - (runtime) if the serialization failspublic static <T> T deserialize(byte[] objectData)
Deserializes a single Object from an array of bytes.
If the call site incorrectly types the return value, a ClassCastException is thrown
from the call site.
Without Generics in this declaration, the call site must type cast and can cause the same
ClassCastException.
Note that in both cases, the ClassCastException is in the call site, not in this method.
T - the object type to be deserializedobjectData - the serialized object, must not be nullIllegalArgumentException - if objectData is nullSerializationException - (runtime) if the serialization failsCopyright © 2017 SDL Group. All rights reserved.