FileDocCategorySizeDatePackage
SerialDemo.javaAPI DocExample1657Sun Feb 03 15:52:34 GMT 2002None

SerialDemo

public class SerialDemo extends Object
Demonstrate use of Serialization.

Fields Summary
protected static final String
FILENAME
Constructors Summary
Methods Summary
public voiddump()

		ObjectInputStream is = new ObjectInputStream(
			new FileInputStream(FILENAME));
		System.out.println(is.readObject());
		is.close();
	
public static voidmain(java.lang.String[] s)


	       
		new SerialDemo().save();
		new SerialDemo().dump();
	
public voidsave()
The save method in an appliction

		ArrayList v = new ArrayList();
		// Gather the data
		MyData u1 = new MyData("Ian Darwin", "secret_java_cook");
		v.add(new Date());
		v.add(u1);
		v.add(new MyData("Abby Brant", "dujordian"));
		write(v);
	
public voidwrite(java.lang.Object theGraph)
Does the actual serialization

		// Save the data to disk.
		ObjectOutputStream os = new ObjectOutputStream(
			new BufferedOutputStream(
				new FileOutputStream(FILENAME)));
		os.writeObject(theGraph);
		os.close();