Class SerializationUtil


  • public final class SerializationUtil
    extends Object
    Miscellaneous serialization utilities
    • Method Detail

      • clone

        public static <T> T clone​(T o)
        Performs a deep copy of the given object via serialization.
        Type Parameters:
        T - the type of the object
        Parameters:
        o - the object to clone
        Returns:
        a copy of the original object
      • toBase64

        public static String toBase64​(Object object)
        Creates a string consisting of the serialized form of the given object.
        Parameters:
        object - the object to serialize
        Returns:
        a string consisting of the serialized form of the given object.
      • toBytes

        public static byte[] toBytes​(Object object)
        Creates a byte array consisting of the serialized form of the given object.
        Parameters:
        object - the object to serialize
        Returns:
        a byte array consisting of the serialized form of the given object.
      • fromBytes

        public static Object fromBytes​(byte[] bytes)
        Creates an object from a byte array.
        Parameters:
        bytes - byte array consisting of the serialized form of a java object.
        Returns:
        the object
        Throws:
        RuntimeException - if errors occur during deserialization
      • fromBase64

        public static Object fromBase64​(String str)
        Creates an object from a base64 encoded byte array.
        Parameters:
        str - string consisting of the base64-encoded serialized form of a java object.
        Returns:
        the object
        Throws:
        RuntimeException - if errors occur during deserialization