|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.onebusaway.utility.ObjectSerializationLibrary
public class ObjectSerializationLibrary
Convenience methods for serializing objects to and from streams and files.
Constructor Summary | |
---|---|
ObjectSerializationLibrary()
|
Method Summary | ||
---|---|---|
static ObjectInputStream |
getFileAsObjectInputStream(File file)
Convenience method to open a specified file as an ObjectInputStream |
|
static ObjectOutputStream |
getFileAsObjectOutputStream(File file)
Convenience method to open a specified file as an ObjectOutputStream |
|
static void |
main(String[] args)
|
|
static void |
printObject(File file,
Object o)
Convenience method to serialize the string representation of an object, as returned by the Object.toString() method, to a file. |
|
static
|
readObject(File file)
Read an object from a file by opening the file as an ObjectInputStream and reading a single object from the stream. |
|
static void |
writeObject(File file,
Object o)
Serialize an object to a file by opening an ObjectOutputStream
linked to the file and writing the object to the stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectSerializationLibrary()
Method Detail |
---|
public static void main(String[] args) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static ObjectOutputStream getFileAsObjectOutputStream(File file) throws IOException
ObjectOutputStream
file
- the target output file
IOException
public static ObjectInputStream getFileAsObjectInputStream(File file) throws IOException
ObjectInputStream
file
- the target input file
IOException
public static void writeObject(File file, Object o) throws IOException
ObjectOutputStream
linked to the file and writing the object to the stream.
file
- the target output fileo
- the object to serialize
IOException
public static <T> T readObject(File file) throws IOException, ClassNotFoundException
ObjectInputStream
and reading a single object from the stream.
file
- the input file
IOException
ClassNotFoundException
public static void printObject(File file, Object o) throws IOException
Object.toString()
method, to a file.
file
- the target output fileo
- the object to serialize
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |