Source Code : Serializing a vector
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Serializing a vector

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;
public class SaveVector {
public static void main(String args[]) throws Exception {
String data[] = { "Java", "Source", "and", "Support", "."};
Vector v = new Vector(Arrays.asList(data));
ByteArrayOutputStream b = new ByteArrayOutputStream();
ObjectOutputStream o = new ObjectOutputStream(b);
o.writeObject(v);
o.close();
ByteArrayInputStream bb = new ByteArrayInputStream(b.toByteArray());
ObjectInputStream oo = new ObjectInputStream(bb);
Vector v2 = (Vector) oo.readObject();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
System.out.println(e.nextElement());
}
}
}
Thank with us