|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectp3j.misc.Serializer
public class Serializer
Class that stores and loads serializable classes. Needed to store and load parameter files. Created on February 12, 2007
Constructor Summary | |
---|---|
Serializer()
|
Method Summary | |
---|---|
protected InputStream |
getInputStream(String file)
Create an input stream. |
protected OutputStream |
getOutputStream(String file)
Create an output stream. |
boolean |
isUsingXML()
|
Object |
load(String file)
Loads object from file. |
Object |
loadFromBinary(String file)
Load object from a binary file. |
Object |
loadFromXML(String file)
Load object from XML file. |
void |
save(Object object,
String file)
Save object to file. |
void |
saveToBinary(Object object,
String file)
Save object to binary file. |
void |
saveToXML(Object object,
String file)
Save object to XML file. |
void |
setUsingXML(boolean usingXML)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Serializer()
Method Detail |
---|
public Object load(String file) throws IOException, ClassNotFoundException
file
- path to file with the object to be loaded
IOException
- if file was not found, file input failed, etc.
ClassNotFoundException
- if class of persistent object could not be foundpublic Object loadFromBinary(String file) throws IOException, ClassNotFoundException
file
- path and file name
IOException
- if file was not found, etc.
ClassNotFoundException
- if class of persistent object could not be foundpublic Object loadFromXML(String file) throws IOException
file
- path and file name
IOException
- if file was not found, a read error occurred, etc.protected InputStream getInputStream(String file) throws IOException
file
- source file
IOException
- if stream creation failsprotected OutputStream getOutputStream(String file) throws IOException
file
- target file
IOException
- if stream creation failspublic void save(Object object, String file) throws IOException
object
- the object to be saved in the filefile
- the file
IOException
- if outputting went wrongpublic void saveToBinary(Object object, String file) throws IOException
object
- the object to be writtenfile
- the target file
IOException
- if writing failspublic void saveToXML(Object object, String file) throws IOException
object
- the object to be writtenfile
- the target file
IOException
- if writing failspublic boolean isUsingXML()
public void setUsingXML(boolean usingXML)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |