Example usage for java.util Enumeration hasMoreElements

List of usage examples for java.util Enumeration hasMoreElements

Introduction

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

Prototype

boolean hasMoreElements();

Source Link

Document

Tests if this enumeration contains more elements.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    FileInputStream is = new FileInputStream("yourfile" + ".keystore");
    KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    String password = "my-keystore-password";
    keystore.load(is, password.toCharArray());

    Enumeration e = keystore.aliases();
    for (; e.hasMoreElements();) {
        String alias = (String) e.nextElement();

        boolean b = keystore.isKeyEntry(alias);

        b = keystore.isCertificateEntry(alias);
    }/*from w  w  w  .  jav  a 2s  .c  om*/
    is.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    ZipFile zf = new ZipFile("your.zip");
    Enumeration e = zf.entries();
    while (e.hasMoreElements()) {
        ZipEntry ze = (ZipEntry) e.nextElement();
        String name = ze.getName();

        long crc = ze.getCrc();
        System.out.println("Its CRC is " + crc);

        String comment = ze.getComment();
        if (comment != null && !comment.equals("")) {
            System.out.println(comment);
        }/*from  w  w  w . j a  v  a  2  s . c  o m*/
        if (ze.isDirectory()) {
            System.out.println(name + " is a directory");
        }
    }
}

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 .  ja v  a 2 s . co  m*/
    }
}

From source file:Main.java

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

    v.add("A");//from w w  w . ja  va  2s . 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());
}

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

    Collection c = ht.values();//from www .j a  va  2 s .c  om
    Iterator itr = c.iterator();
    while (itr.hasNext()) {
        System.out.println(itr.next());
    }
    c.remove("One");

    Enumeration e = ht.elements();

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

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 a va2s .c  o  m*/
        if (je.isDirectory()) {
            System.out.println(name + " is a directory");
        }

    }
}

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());
    }//from   www  . j  a va2  s  .  com

    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[]) throws IOException {

    JarFile jarFile = new JarFile("c:/abc/yourJarFileName.jar");
    Enumeration<JarEntry> e = jarFile.entries();
    while (e.hasMoreElements()) {
        process(e.nextElement());/* www. ja v  a 2  s. c  o  m*/
    }
    jarFile.close();
}

From source file:Main.java

public static void main(String args[]) throws IOException {

    JarFile jarFile = new JarFile(new File("c:/abc/yourJarFileName.jar"));
    Enumeration<JarEntry> e = jarFile.entries();
    while (e.hasMoreElements()) {
        process(e.nextElement());// w  ww  .  j  av  a 2  s  . c  o  m
    }
    jarFile.close();
}

From source file:collection.java

public static void main(String args[]) {
    Enumeration e = new collection();
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }//from w ww.j a  va  2 s. c om
}