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:DumpProps.java

public static void main(String args[]) {
    Properties props = System.getProperties();
    Iterator iter = props.entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry entry = (Map.Entry) iter.next();
        System.out.println(entry.getKey() + " --- " + entry.getValue());
    }/*www  . j  a v a  2s  .  c o  m*/

    System.out.println("-------");

    Enumeration e = props.propertyNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " --- " + props.getProperty(key));
    }
}

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

    Set st = ht.keySet();//from   w  w  w. j  ava  2s .co  m

    Iterator itr = st.iterator();

    while (itr.hasNext()) {
        System.out.println(itr.next());
    }
    st.remove("2");

    Enumeration e = ht.keys();
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Vector<String> v = new Vector<String>();
    v.add("a");/*from   w  ww. j a  va  2 s.  c o m*/
    v.add("b");
    v.add("java2s.com");

    Collection<String> col = v;
    Enumeration<String> 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 args[]) throws Exception {
    Vector<String> v = new Vector<String>();
    v.add("a");/*from   w ww  .  ja v a2s. c  o  m*/
    v.add("b");
    v.add("c");

    Collection<String> col = v;
    Enumeration<String> e = Collections.enumeration(col);

    for (; e.hasMoreElements();) {
        Object o = e.nextElement();
        System.out.println(o);
    }
}

From source file:MainClass.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();

        long crc = je.getCrc();
        System.out.println("Its CRC is " + crc);
        String comment = je.getComment();
        if (comment != null && !comment.equals("")) {
            System.out.println(comment);
        }/*  w w w  . j av a  2 s.c  o m*/
        if (je.isDirectory()) {
            System.out.println(name + " is a directory");
        }

    }
}

From source file:Main.java

public static void main(String[] args) {
    HashSet<String> hashSet = new HashSet<String>();

    hashSet.add("A");
    hashSet.add("B");
    hashSet.add("D");
    hashSet.add("E");
    hashSet.add("F");

    Enumeration e = Collections.enumeration(hashSet);
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }// w  w w  .  j a va  2s .  c o  m
}

From source file:Main.java

public static void main(String[] args) {

    HashMap<String, String> hMap = new HashMap<String, String>();

    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    Hashtable<String, String> ht = new Hashtable<String, String>();
    ht.put("1", "REPLACED !!");
    ht.put("4", "Four");

    Enumeration e = ht.elements();
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }/*  ww w  .  j ava2  s .c om*/

    ht.putAll(hMap);
    e = ht.elements();

    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }
}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<String> arrayList = new ArrayList<String>();

    arrayList.add("A");
    arrayList.add("B");
    arrayList.add("D");
    arrayList.add("E");
    arrayList.add("F");

    Enumeration e = Collections.enumeration(arrayList);

    while (e.hasMoreElements())
        System.out.println(e.nextElement());
}

From source file:Main.java

public static void main(String[] args) {
    ResourceBundle resource = ResourceBundle.getBundle("Messages", Locale.UK);

    Properties properties = convertResourceBundleToProperties(resource);

    Enumeration keys = properties.keys();
    while (keys.hasMoreElements()) {
        String key = (String) keys.nextElement();
        String value = (String) properties.get(key);
        System.out.println(key + " = " + value);
    }// w w w .  ja  v  a2s. co m
}

From source file:MainClass.java

public static void main(String args[]) throws IOException {
    Hashtable map = new Hashtable();
    FileReader fr = new FileReader(args[0]);
    BufferedReader br = new BufferedReader(fr);
    String line;/*w  w w . ja  v a2  s . c o  m*/
    while ((line = br.readLine()) != null) {
        processLine(line, map);
    }
    Enumeration e = map.keys();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " : " + map.get(key));
    }
}