public class SerializableUtil extends Object
Serializable objects
from files, streams and readers. This class encapsulates all the common
serializing code and type casting to allow a clean interface for classes that
need to interact with serialized objects. All checked IOException
cases are rethrown as IOError.| Modifier and Type | Method and Description |
|---|---|
static <T> T |
load(File file)
Loads a serialized object of the specifed type from the file.
|
static <T> T |
load(File file,
Class<T> type)
Loads a serialized object of the specifed type from the file.
|
static <T> T |
load(InputStream stream)
Loads a serialized object of the specifed type from the stream.
|
static <T> T |
load(String fileName)
Loads a serialized object of the specifed type from the file.
|
static byte[] |
save(Object o)
Serializes the object to a
byte array. |
static void |
save(Object o,
File file)
Serializes the object to the provided file.
|
static void |
save(Object o,
OutputStream stream)
Serializes the object to the provided stream.
|
static void |
save(Object o,
String file)
Serializes the object to the provided file.
|
public static void save(Object o, String file)
o - the object to be stored in the filefile - the file in which the object should be storedpublic static void save(Object o, File file)
o - the object to be stored in the filefile - the file in which the object should be storedpublic static void save(Object o, OutputStream stream)
o - the object to be stored in the filestream - the stream in which the object should be storedpublic static byte[] save(Object o)
byte array.o - the object to be stored in the filepublic static <T> T load(File file, Class<T> type)
file - the file from which a mapping should be loadedtype - the type of the object being deserializedpublic static <T> T load(String fileName)
fileName - the file name from which an object should be loadedpublic static <T> T load(File file)
file - the file from which a mapping should be loadedpublic static <T> T load(InputStream stream)
file - the file from which a mapping should be loadedtype - the type of the object being deserializedCopyright © 2012. All Rights Reserved.