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[] 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();//  w  w w  .  java  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> 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);
    }/*from w w w . jav  a2s.c  o m*/
}

From source file:Main.java

public static void main(String args[]) {
    ProtectionDomain domain = "".getClass().getProtectionDomain();

    PermissionCollection pcoll = Policy.getPolicy().getPermissions(domain);

    Enumeration e = pcoll.elements();
    for (; e.hasMoreElements();) {
        Permission p = (Permission) e.nextElement();
        System.out.println(p);//w  w  w.  jav a  2s. com

    }
}

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   w  w  w .  ja  v a2 s  .c o  m
}

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.elements();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " : " + table.get(key));
    }//  www  .j a  v  a  2 s . c o  m

    System.out.println(table.values());
}

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));
    }//  ww  w.  ja  v  a2 s.c o  m

    System.out.println(table.values());
}

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. ja  v  a  2  s .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: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  w w  w  .  j a va 2 s .c o m*/
        }
        in.close();
        fout.close();
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String zipname = "data.zip";
    ZipFile zipFile = new ZipFile(zipname);
    Enumeration enumeration = zipFile.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
        System.out.println(zipEntry.getCrc());
    }/*w w w . jav  a 2 s  .com*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String zipname = "data.zip";
    ZipFile zipFile = new ZipFile(zipname);
    Enumeration enumeration = zipFile.entries();
    while (enumeration.hasMoreElements()) {
        ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
        System.out.println(zipEntry.toString());
    }//from  w  w w. ja  v a 2 s.c  o  m
}