public class SerializationHelper extends Object
Provide common functionalities for serialization of object.
This class throws exceptions for invalid null inputs.
Each method documents its behaviour in more detail.
| Constructor and Description |
|---|
SerializationHelper() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
clone(Serializable object)
Deep clone a Serializable object using serialization.
|
static Object |
deserialize(byte[] objectBytes)
Deserialize an object from a byte array
|
static Object |
deserialize(InputStream inputStream)
Deserialze an object from an InputStream
|
static byte[] |
serialize(Serializable obj)
Serialize the object to a byte array
|
static void |
serialize(Serializable obj,
OutputStream outputStream)
Serialize the object to an OutputStream
|
public static Object clone(Serializable object) throws IOException, ClassNotFoundException
Deep clone a Serializable object using serialization.
the - serializable objectIOException, - ClassNotFoundExceptionIOExceptionClassNotFoundExceptionpublic static void serialize(Serializable obj, OutputStream outputStream) throws IOException
obj - the object to serialize to bytesoutputStream - the stream to write to, can not be nullIOExceptionpublic static byte[] serialize(Serializable obj) throws IOException
obj - the object to serialize to bytesIOExceptionpublic static Object deserialize(InputStream inputStream) throws IOException, ClassNotFoundException
inputStream - the serialized object input stream, must not be nullIOException, - ClassNotFoundExceptionIOExceptionClassNotFoundExceptionpublic static Object deserialize(byte[] objectBytes) throws IOException, ClassNotFoundException
objectBytes - the serialized object, can not be nullIOException, - ClassNotFoundExceptionIOExceptionClassNotFoundExceptionCopyright © 2023. All rights reserved.