public final class SerializationUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.io.IOException |
NOT_VALID_CLASS
Exception thrown when deserializing and assigning to a not valid class type.
|
Modifier | Constructor and Description |
---|---|
private |
SerializationUtils()
Private constructor for avoiding instantiation.
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
deserialize(java.io.File file,
java.lang.Class<T> target)
Deserializes the given file into an object
instance of the given target class.
|
static void |
serialize(java.io.Serializable object,
java.io.File file)
Serializes the given object into the given file.
|
private static final java.io.IOException NOT_VALID_CLASS
private SerializationUtils()
public static void serialize(java.io.Serializable object, java.io.File file) throws java.io.IOException
object
- Object to serialize.file
- File to serialize object into.java.io.IOException
- If any error occurs while writing file.public static <T> T deserialize(java.io.File file, java.lang.Class<T> target) throws java.io.IOException, java.lang.ClassNotFoundException
file
- File to deserialize.target
- Target class that object will be deserialize into.java.io.IOException
- If any error occurs while reading file content.java.lang.ClassNotFoundException
- If any error occurs while retrieving serialized object class.