public class JavaBinarySerializer extends java.lang.Object implements ISerializer
Serialization with JavaBinarySerializer.
// Some class to be serialized. public class MyClass implements Serializable { private static final long serialVersionUID = -8325844480504249827L; public String myData; } // Create the serializer. JavaBinarySerializer aSerializer = new JavaBinarySerializer(); // Create some data to be serialized. MyClass aData = new MyClass(); ... // Serialize data. object aSerializedData = aSerializer.serialize(aData, MyClass.class); // Deserialize data. MyClass aDeserializedData = aSerializer.deserialize(aSerializedData, MyClass.class);
Constructor and Description |
---|
JavaBinarySerializer() |
Modifier and Type | Method and Description |
---|---|
<T> T |
deserialize(java.lang.Object serializedData,
java.lang.Class<T> clazz)
Deserializes data with using ObjectInputStream.
|
<T> java.lang.Object |
serialize(T dataToSerialize,
java.lang.Class<T> clazz)
Serializes data with using ObjectOutputStream.
|
public <T> java.lang.Object serialize(T dataToSerialize, java.lang.Class<T> clazz) throws java.lang.Exception
serialize
in interface ISerializer
dataToSerialize
- Data to be serialized.clazz
- represents the serialized type.java.lang.Exception
- If the serialization fails.public <T> T deserialize(java.lang.Object serializedData, java.lang.Class<T> clazz) throws java.lang.Exception
deserialize
in interface ISerializer
serializedData
- Data to be deserialized.java.lang.Exception
- If the deserialization fails.