Save Vector to file : Vector « Collections Data Structure « Java

Save Vector to file

import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;

public class SaveVector1 {
  public static void main(String args[]) throws Exception {
    Vector v = new Vector(Arrays.asList(args));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bais);
    Vector v2 = (Vector) ois.readObject();
    Enumeration e = v.elements();
    while (e.hasMoreElements()) {


Related examples in the same category

1.Use Vector in java.utilUse Vector in java.util
2.Finding elements in a vectorFinding elements in a vector
3.Serializing a vectorSerializing a vector
4.Create Vector test
5.Find Vector Find Vector
6.Remove Element in Vector
7.Sequence Sequence
8.Vector Util
9.Iterator out of Vector
10.Copy Elements of One Java Vector to Another Java Vector
11.Copy Elements of Vector to Java ArrayList
12.Create Java ArrayList From Enumeration
13.Find maximum element of Java Vector
14.Find Minimum element of Java Vector
15.Get Enumeration over Java Vector
16.Perform Binary Search on Java Vector
17.Replace All Elements Of Java Vector
18.Replace all occurrences of specified element of Java Vector
19.Reverse order of all elements of Java Vector
20.Shuffle elements of Java Vector
21.Swap elements of Java Vector
22.Sort Java Vector in descending order using comparator
23.Enumerate through a Vector using Java Enumeration
24.Append all elements of other Collection to Java Vector
25.Copy all elements of Java Vector to an Object Array
26.Get Size of Java Vector and loop through the elements
27.Get Sub List of Java Vector Example
28.Insert all elements of other Collection to Specified Index of Java Vector
29.Iterate through elements Java Vector using Iterator
30.Iterate through elements Java Vector using ListIterator
31.Remove all elements from Java Vector
32.Remove an element from specified index of Java Vector
33.Remove specified element from Java Vector
34.Replace an element at specified index of Java Vector
35.Search an element of Java Vector
36.Search an element of Java Vector from specific index
37.Set size of Java Vector Example
38.Sort elements of Java Vector
39.Generic Vector with String
40.Count distinct elements in a Vector
41.Unmodifiable Vector Adapter
42.Adaptive extension of the java.util.Vector class