Class Serializer

java.lang.Object
is.codion.common.Serializer

public final class Serializer extends Object
Utility class for serialization.
  • Method Details

    • serialize

      public static byte[] serialize(Object object) throws IOException
      Serializes the given Object, null object results in an empty byte array
      Parameters:
      object - the object
      Returns:
      a byte array representing the serialized object, an empty byte array in case of null
      Throws:
      IOException - in case of an exception
    • deserialize

      public static <T> T deserialize(byte[] bytes) throws IOException, ClassNotFoundException
      Deserializes the given byte array into a T, null or an empty byte array result in a null return value
      Type Parameters:
      T - the type of the object represented in the byte array
      Parameters:
      bytes - a byte array representing the serialized object
      Returns:
      the deserialized object
      Throws:
      IOException - in case of an exception
      ClassNotFoundException - in case the deserialized class is not found