List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(3); v.add(new FileInputStream("/a/b")); v.add(new FileInputStream("yourfile.bar")); v.add(new FileInputStream("/yourfile.txt")); Enumeration e = v.elements(); SequenceInputStream sis = new SequenceInputStream(e); InputStreamReader isr = new InputStreamReader(sis); BufferedReader br = new BufferedReader(isr); String line;//from w ww. j a v a 2 s. c o m while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); }
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; 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 w ww. j ava 2 s .com*/ }
From source file:Main.java
public static void main(String[] args) throws IOException { Vector theStreams = new Vector(); for (int i = 0; i < args.length; i++) { FileInputStream fin = new FileInputStream(args[i]); theStreams.addElement(fin);/*from w w w . ja v a 2 s . c o m*/ } InputStream in = new SequenceInputStream(theStreams.elements()); for (int i = in.read(); i != -1; i = in.read()) { System.out.write(i); } }
From source file:Utilities.java
public static void main(String[] args) { List list = Arrays.asList("one Two three Four five six one".split(" ")); System.out.println(list);//from w ww . ja v a 2s . c o m System.out.println("max: " + Collections.max(list)); System.out.println("min: " + Collections.min(list)); AlphabeticComparator comp = new AlphabeticComparator(); System.out.println("max w/ comparator: " + Collections.max(list, comp)); System.out.println("min w/ comparator: " + Collections.min(list, comp)); List sublist = Arrays.asList("Four five six".split(" ")); System.out.println("indexOfSubList: " + Collections.indexOfSubList(list, sublist)); System.out.println("lastIndexOfSubList: " + Collections.lastIndexOfSubList(list, sublist)); Collections.replaceAll(list, "one", "Yo"); System.out.println("replaceAll: " + list); Collections.reverse(list); System.out.println("reverse: " + list); Collections.rotate(list, 3); System.out.println("rotate: " + list); List source = Arrays.asList("in the matrix".split(" ")); Collections.copy(list, source); System.out.println("copy: " + list); Collections.swap(list, 0, list.size() - 1); System.out.println("swap: " + list); Collections.fill(list, "pop"); System.out.println("fill: " + list); List dups = Collections.nCopies(3, "snap"); System.out.println("dups: " + dups); // Getting an old-style Enumeration: Enumeration e = Collections.enumeration(dups); Vector v = new Vector(); while (e.hasMoreElements()) v.addElement(e.nextElement()); // Converting an old-style Vector // to a List via an Enumeration: ArrayList arrayList = Collections.list(v.elements()); System.out.println("arrayList: " + arrayList); }
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);//from ww w.j a v a2s . c o 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: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);/*from w ww . ja v a 2 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:SaveVector1.java
public static void main(String args[]) throws Exception { Vector v = new Vector(Arrays.asList(args)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(v);/*from www . j a v a 2 s .co 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:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(Arrays.asList("a", "b", "c")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(v);/*from ww w. j a v a 2s . com*/ 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:org.smartfrog.avalanche.client.sf.apps.gt4.security.GridSecurity.java
public static void main(String args[]) { //GridSecurity sec = new GridSecurity("/home/sandya/globus401"); //String policy = null; //try {//from w w w. j a v a2 s .c o m //sec.setup(); /*Properties props = new Properties(); props.setProperty("-force", ""); sec.reqHostCert("eb96133.india.hp.com", props); File certReq = new File("/etc/grid-security/hostcert_request.pem"); File destDir = new File("/etc/grid-security"); sec.getSignedCert(certReq, destDir, "hostcert.pem"); */ //sec.setContainerCredentials(); //String subject = sec.getUserSubject(); //sec.updateGridMapfile(subject, System.getProperty("user.name")); /*Properties p = new Properties(); p.setProperty("-passphrase", "iso*help"); sec.reqUserCert(p); File userReq = new File("/home/sandya/.globus/usercert_request.pem"); File userDir = new File("/home/sandya/.globus"); */ //sec.getSignedCert(userReq, userDir, "usercert.pem"); Vector v = new Vector(); v.add(0, "test<GLOBUS_LOCATION>"); v.add(1, "for"); v.add(2, "vector"); Enumeration e = v.elements(); while (e.hasMoreElements()) { String element = (String) e.nextElement(); String el = element.replaceAll("<GLOB_LOCATION>", "/home/globus"); System.out.println("Vector Element : " + el); } //} catch (GT4SecurityException gse) { //log.error(gse); //} }
From source file:com.pervasive07.MsgReader.java
public static void main(String[] args) throws Exception { String source = null;//w w w . j a v a 2 s. c o m Vector v = new Vector(); if (args.length > 0) { for (int i = 0; i < args.length; i++) { if (args[i].equals("-comm")) { source = args[++i]; } else { String className = args[i]; try { Class c = Class.forName(className); Object packet = c.newInstance(); Message msg = (Message) packet; if (msg.amType() < 0) { System.err.println(className + " does not have an AM type - ignored"); } else { v.addElement(msg); } } catch (Exception e) { System.err.println(e); } } } } else if (args.length != 0) { usage(); System.exit(1); } MsgReader mr = new MsgReader(source); Enumeration msgs = v.elements(); while (msgs.hasMoreElements()) { Message m = (Message) msgs.nextElement(); mr.addMsgType(m); } mr.start(); }