public class ObjectSerializationUtils {
/**
- * Serialize an object to a byte array.
- * @param aObject Object ot serialize.
+ * Serialize an object to a byte array.
+ *
+ * @param aObject
+ * Object ot serialize.
* @return Byte array.
* @throws IOException
*/
public static byte[] serialize(Object aObject) throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bos);
os.writeObject(aObject);
os.flush();
return bos.toByteArray();
}
-
+
/**
- * Desrializes an object from a byte array.
- * @param <T> Type of the object.
- * @param aData Serialized data.
- * @param aType Type of the object.
- * @return Object.
+ * Desrializes an object from a byte array.
+ *
+ * @param <T>
+ * Type of the object.
+ * @param aData
+ * Serialized data.
+ * @param aType
+ * Type of the object.
+ * @return Object.
* @throws IOException
* @throws ClassNotFoundException
*/
- public static <T> T deserialize(byte[] aData, Class<T> aType) throws IOException, ClassNotFoundException {
- ByteArrayInputStream bis = new ByteArrayInputStream(aData);
- ObjectInputStream os = new ObjectInputStream(bis);
- return (T)os.readObject();
+ public static <T> T deserialize(byte[] aData, Class<T> aType)
+ throws IOException, ClassNotFoundException {
+ ByteArrayInputStream bis = new ByteArrayInputStream(aData);
+ ObjectInputStream os = new ObjectInputStream(bis);
+ return (T) os.readObject();
}
}