SerializableVector sv1 = new SerializableVector();
sv1.addElement("Element 1");
sv1.addElement(new Integer(9));
sv1.addElement(new URL("http://www.oreilly.com/"));
// not Serializable
sv1.addElement(new Socket("www.ora.com", 80));
sv1.addElement("Element 1");
sv1.addElement(new Integer(9));
sv1.addElement(new URL("http://www.oreilly.com/"));
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream temp = new ObjectOutputStream(bout);
temp.writeObject(sv1);
temp.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream oin = new ObjectInputStream(bin);
Vector v = (Vector) oin.readObject();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
System.out.println(e.nextElement());
}