List of usage examples for java.util Enumeration nextElement
E nextElement();
From source file:Main.java
public static void main(String[] s) { Hashtable<String, String> table = new Hashtable<String, String>(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); Enumeration e = table.elements(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + table.get(key)); }/* w w w. j a v a 2s .c o m*/ System.out.println(table.values()); }
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 w ww.ja v a 2 s . 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:Main.java
public static void main(String[] args) { Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "One"); ht.put("2", "Two"); ht.put("3", "Three"); Object obj = ht.remove("2"); System.out.println(obj + " was Removed "); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }/* w w w . ja v a2 s . c o m*/ }
From source file:MainClass.java
public static void main(String args[]) { Vector vector = new Vector(); vector.addElement(new Integer(5)); vector.addElement(new Float(-14.14f)); vector.addElement(new String("Hello")); Enumeration e = vector.elements(); while (e.hasMoreElements()) { Object obj = e.nextElement(); System.out.println(obj);/* w w w . j ava2 s .co m*/ } }
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 w w.j a v a2s. c om*/ 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 { Properties p = new Properties(); p.load(new FileInputStream("test.txt")); Enumeration e = p.propertyNames(); for (; e.hasMoreElements();) { System.out.println(e.nextElement()); }/*from w w w . ja v a2 s .com*/ }
From source file:Main.java
public static void main(String[] args) throws IOException { ZipFile zf = new ZipFile("a.zip"); Enumeration e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); FileOutputStream fout = new FileOutputStream(ze.getName()); InputStream in = zf.getInputStream(ze); for (int c = in.read(); c != -1; c = in.read()) { fout.write(c);/*from ww w .ja va 2 s. c o m*/ } in.close(); fout.close(); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(); v.add("a");/*from w ww . j a va 2 s. c o m*/ v.add("b"); v.add("c"); Collection col = v; Enumeration e = Collections.enumeration(col); for (; e.hasMoreElements();) { Object o = e.nextElement(); System.out.println(o); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Properties props = System.getProperties(); Enumeration e = props.propertyNames(); for (; e.hasMoreElements();) { String propName = (String) e.nextElement(); System.out.println(propName); String propValue = (String) props.get(propName); System.out.println(propValue); }/*from ww w .ja v a 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("A");/*ww w . ja va 2 s .co m*/ v.add("B"); v.add("D"); v.add("E"); v.add("F"); Enumeration e = Collections.enumeration(v); while (e.hasMoreElements()) System.out.println(e.nextElement()); }