Class SerializationUtils


  • public class SerializationUtils
    extends Object
    • Constructor Detail

      • SerializationUtils

        protected SerializationUtils()
    • Method Detail

      • readObject

        public static <T> T readObject​(File file)
      • readObject

        public static <T> T readObject​(InputStream is)
        Reads an object from the given input stream
        Parameters:
        is - the input stream to read from
        Returns:
        the read object
      • toByteArray

        public static byte[] toByteArray​(Serializable toSave)
        Converts the given object to a byte array
        Parameters:
        toSave - the object to save
      • fromByteArray

        public static <T> T fromByteArray​(byte[] bytes)
        Deserializes object from byte array
        Type Parameters:
        T -
        Parameters:
        bytes -
        Returns:
      • deserialize

        public static <T> T deserialize​(byte[] bytes)
        Deserializes object from byte array
        Type Parameters:
        T -
        Parameters:
        bytes -
        Returns:
      • deserialize

        public static <T> T deserialize​(InputStream is)
        Deserializes object from InputStream
        Type Parameters:
        T -
        Parameters:
        bytes -
        Returns:
      • writeObject

        public static void writeObject​(Serializable toSave,
                                       OutputStream writeTo)
        Writes the object to the output stream THIS DOES NOT FLUSH THE STREAM
        Parameters:
        toSave - the object to save
        writeTo - the output stream to write to
      • serialize

        public static void serialize​(Serializable object,
                                     OutputStream os)
        Writes the object to the output stream THIS DOES NOT FLUSH THE STREAM
        Parameters:
        toSave - the object to save
        writeTo - the output stream to write to
      • saveObject

        public static void saveObject​(Object toSave,
                                      File saveTo)