| Modifier and Type | Field and Description |
|---|---|
private InputStream |
fis
The
InputStream for serialization. |
private OutputStream |
fos
The
OutputStream for serialization. |
private static org.apache.log4j.Logger |
logger
Custom logger.
|
private ObjectInputStream |
ois
The
ObjectInputStream for serialization. |
private ObjectOutputStream |
oos
The
ObjectOutputStream for serialization. |
| Constructor and Description |
|---|
Serializer()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
deserialize(File f)
Deserialize an object from a given binary file.
|
static byte[] |
getBytes(Object o)
Serializes an
Object into a byte[]. |
static Object |
getObject(byte[] data)
Deserializes an
byte[] to an Object. |
void |
serialize(Object o,
File f)
Serialize an
Object to a file on the hard drive. |
private static final org.apache.log4j.Logger logger
private OutputStream fos
OutputStream for serialization.private ObjectOutputStream oos
ObjectOutputStream for serialization.private InputStream fis
InputStream for serialization.private ObjectInputStream ois
ObjectInputStream for serialization.public void serialize(Object o, File f) throws FileNotFoundException, IOException
Object to a file on the hard drive. Each object to
be serialized has to implement the Serializable interface.o - the Objectf - the locationFileNotFoundException - if the file cannot be locatedIOException - if the file cannot be read or writtenpublic Object deserialize(File f) throws FileNotFoundException, IOException, ClassNotFoundException
Serializable interface.f - the file on the hard driveObjectFileNotFoundException - if the file cannot be locatedIOException - if the file cannot be read or writtenClassNotFoundException - if the object cannot be restored into a class on the
class pathpublic static byte[] getBytes(Object o)
Object into a byte[]. Each object to
be serialized has to implement the Serializable interface.o - the object to be serializedpublic static Object getObject(byte[] data)
byte[] to an Object. Each object to
be deserialized has to implement the Serializable interface.data - the byte arrayCopyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.