Example usage for java.util Enumeration nextElement

List of usage examples for java.util Enumeration nextElement

Introduction

In this page you can find the example usage for java.util Enumeration nextElement.

Prototype

E nextElement();

Source Link

Document

Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Usage

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Vector v = new Vector();
    v.add("a");//  ww w  . j  a v  a2 s.c  om
    v.add("b");
    v.add("c");

    Enumeration e = v.elements();
    while (e.hasMoreElements()) {
        Object o = e.nextElement();
        System.out.println(o);
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Vector<String> v = new Vector<String>();
    v.add("A");//  ww w  .  ja v a  2s. c o  m
    v.add("B");

    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");

    Enumeration e = ht.keys();

    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }/*from  www .j  a  v  a 2 s .  co m*/
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {
    ZipFile zf = new ZipFile("test.zip");
    Enumeration e = zf.entries();
    while (e.hasMoreElements()) {
        ZipEntry ze2 = (ZipEntry) e.nextElement();
        System.out.println("File: " + ze2);
    }/*from ww  w.  j  a va 2s . c  om*/
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    JarFile jf = new JarFile(args[0]);
    Enumeration e = jf.entries();
    while (e.hasMoreElements()) {
        JarEntry je = (JarEntry) e.nextElement();
        String name = je.getName();
        System.out.println(name);
    }//from   w ww.  j av a2  s  .c o  m
}

From source file:Main.java

public static void main(String args[]) {
    Hashtable<String, String> hash = new Hashtable<String, String>();
    hash.put("1", "one");
    hash.put("2", "two");
    hash.put("3", "three");

    Enumeration keys = hash.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = hash.get(key);

        System.out.println(key + " : " + value);
    }//w  ww  .  j av a 2 s  . co m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties config = new Properties();
    config.load(new FileInputStream("conf-file.pros"));

    Enumeration en = config.keys();
    while (en.hasMoreElements()) {
        String key = (String) en.nextElement();
        System.out.println(key + ":" + config.get(key));
    }/*from w  w w.  j a  va 2s  . c  om*/
}

From source file:MainClass.java

public static void main(String[] s) {
    Hashtable table = new Hashtable();
    table.put("key1", "value1");
    table.put("key2", "value2");
    table.put("key3", "value3");

    Enumeration e = table.keys();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " : " + table.get(key));
    }/*from w  w  w. j  a v  a2s.  c  o m*/
}

From source file:Main.java

public static void main(String[] args) {
    Hashtable h = new Hashtable(20);

    System.out.println(h.put("one", new Integer(1)));
    System.out.println(h.put("name", "A"));
    System.out.println(h.put("date", new Date()));
    System.out.println(h.put("one", new Integer(4)));

    Enumeration e = h.keys();
    while (e.hasMoreElements())
        System.out.println(e.nextElement());

    e = h.elements();//from ww  w . j  a v a  2 s.  c o m
    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");

    Enumeration e = ht.elements();

    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }/* ww  w.  j a va2s.  co  m*/
}