kaapo.filemanager
Class ObjectSerializer

java.lang.Object
  extended by kaapo.filemanager.ObjectSerializer

public class ObjectSerializer
extends Object

A reusable class to simplify object serialization to disk. Has methods for writing any serializable objects to a file and reading them back.

Author:
paltamaa

Constructor Summary
ObjectSerializer()
          Constructs a new ObjectSerializer.
 
Method Summary
 Object read(File file)
          Reads an object from a file.
 void write(Object object, File file)
          Writes an object to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectSerializer

public ObjectSerializer()
Constructs a new ObjectSerializer.

Method Detail

read

public Object read(File file)
            throws IOException,
                   ClassNotFoundException
Reads an object from a file.

Parameters:
file - the file to be opened for reading
Returns:
object from the file
Throws:
IOException - if an I/O error occurs
ClassNotFoundException

write

public void write(Object object,
                  File file)
           throws IOException
Writes an object to a file.

Parameters:
object - the object to save
file - the file to be opened for writing
Throws:
IOException - if an I/O error occurs