Package io.bhagat.util
Class SerializableUtil
- java.lang.Object
-
- io.bhagat.util.SerializableUtil
-
public class SerializableUtil extends java.lang.ObjectA class that will use static methods to serialize and deserialize objects- Author:
- Bhagat
-
-
Constructor Summary
Constructors Constructor Description SerializableUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tdeserialize(java.lang.String filename)retrieves a serialized object from the diskstatic voidserialize(java.io.Serializable obj, java.lang.String filename)will serialize an object into a file
-
-
-
Method Detail
-
serialize
public static void serialize(java.io.Serializable obj, java.lang.String filename) throws java.io.IOExceptionwill serialize an object into a file- Parameters:
obj- the object to serializefilename- 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.IOExceptionretrieves 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 classjava.io.IOException- if an IOException is thrown during the reading of the object
-
-