X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fgeneral%2FObjectSerializationUtils.java;h=db8534a9e81035884c3f0ee3a694139dc955c70b;hb=4a575582a5c2999bd816b197d9cf274b4b3ddcd7;hp=1b820f03dd08af1b5b09ab62d9229195b0347a71;hpb=7d3754ca3d757ef89241cdbd679f82941e64cfc6;p=utils diff --git a/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java b/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java index 1b820f03..db8534a9 100644 --- a/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java +++ b/support/general/src/main/java/org/wamblee/general/ObjectSerializationUtils.java @@ -29,31 +29,38 @@ import java.io.ObjectOutputStream; 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 Type of the object. - * @param aData Serialized data. - * @param aType Type of the object. - * @return Object. + * Desrializes an object from a byte array. + * + * @param + * Type of the object. + * @param aData + * Serialized data. + * @param aType + * Type of the object. + * @return Object. * @throws IOException * @throws ClassNotFoundException */ - public static T deserialize(byte[] aData, Class aType) throws IOException, ClassNotFoundException { - ByteArrayInputStream bis = new ByteArrayInputStream(aData); - ObjectInputStream os = new ObjectInputStream(bis); - return (T)os.readObject(); + public static T deserialize(byte[] aData, Class aType) + throws IOException, ClassNotFoundException { + ByteArrayInputStream bis = new ByteArrayInputStream(aData); + ObjectInputStream os = new ObjectInputStream(bis); + return (T) os.readObject(); } }