List of usage examples for java.util Vector Vector
public Vector(Collection<? extends E> c)
From source file:MainClass.java
public static void main(String args[]) throws Exception { String[] a = new String[] { "a", "b", "c" }; Vector v = new Vector(Arrays.asList()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(v);// w ww . j a v a2 s . c o m oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); Vector v2 = (Vector) ois.readObject(); Enumeration e = v.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:SaveVector.java
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);// ww w .j a v a2 s .co m 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()); } }
From source file:EnumerationIterator1.java
public static void main(String args[]) { String elements[] = { "Java", "Source", "and", "Support", "." }; Vector v = new Vector(Arrays.asList(elements)); Enumeration e = v.elements(); Iterator itor = EnumerationIterator1.iterator(e); while (itor.hasNext()) { System.out.println(itor.next()); }//w w w. jav a 2 s . c o m }
From source file:ArrayToVector.java
public static void main(String[] args) { Object[] a1d = { "Hello World", new Date(), Calendar.getInstance(), }; // Arrays.asList(Object[]) --> List List l = Arrays.asList(a1d); // Vector contstructor takes Collection // List is a subclass of Collection Vector v;/*w ww . j a v a2 s. c o m*/ v = new Vector(l); // Or, more simply: v = new Vector(Arrays.asList(a1d)); // Just to prove that it worked. Enumeration e = v.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:Main.java
public static Vector toVector(Object[] source) { final Vector vec = new Vector(source.length); for (int i = 0; i < source.length; i++) { vec.addElement(source[i]);/* ww w . j a va 2s .co m*/ } return vec; }
From source file:Main.java
public static Vector asVector(java.util.List list) { return list instanceof Vector ? (Vector) list : new Vector(list); }
From source file:Main.java
public static Collection or(Collection collection1, Collection collection2) { Vector completeList = new Vector(collection1); if (collection2 == null) return collection1; Iterator i = collection2.iterator(); // Do the long way tro make sure no dups while (i.hasNext()) { Object addlItem = i.next(); if (collection1.contains(addlItem) == false) { completeList.addElement(addlItem); }/*from w w w . jav a 2 s .com*/ } return completeList; }
From source file:Main.java
public static <GPType> List<GPType> asList(final GPType node) { final List<GPType> list = new Vector<GPType>(1); list.add(node);//from w w w.j a va 2s . c o m return list; }
From source file:Main.java
public static <K> Vector<K> newVector(int size) { return new Vector<K>(size); }
From source file:Main.java
public static Vector<Long> convertToVectorOfLongs(long[] a_aLongArray) /* */ {//from ww w .jav a 2s .c om /* 487 */Vector vecReturn = null; /* 488 */if (a_aLongArray != null) /* */ { /* 490 */vecReturn = new Vector(a_aLongArray.length); /* 491 */for (long lLong : a_aLongArray) /* */ { /* 493 */vecReturn.add(Long.valueOf(lLong)); /* */} /* */} /* */ /* 497 */return vecReturn; /* */}