Class SerializableUtil


  • public class SerializableUtil
    extends java.lang.Object
    A class that will use static methods to serialize and deserialize objects
    Author:
    Bhagat
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T deserialize​(java.lang.String filename)
      retrieves a serialized object from the disk
      static void serialize​(java.io.Serializable obj, java.lang.String filename)
      will serialize an object into a file
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SerializableUtil

        public SerializableUtil()
    • Method Detail

      • serialize

        public static void serialize​(java.io.Serializable obj,
                                     java.lang.String filename)
                              throws java.io.IOException
        will serialize an object into a file
        Parameters:
        obj - the object to serialize
        filename - the filename of where to store the object
        Throws:
        java.io.IOException - if it is thrown by writing the object
      • deserialize

        public static <T> T deserialize​(java.lang.String filename)
                                 throws java.lang.ClassNotFoundException,
                                        java.io.IOException
        retrieves a serialized object from the disk
        Type Parameters:
        T - x the type of the object
        Parameters:
        filename - the filename where the object is stored
        Returns:
        the object
        Throws:
        java.lang.ClassNotFoundException - the retrieved object is not of a known class
        java.io.IOException - if an IOException is thrown during the reading of the object