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

@SuppressWarnings("unchecked")
public static List<ZipEntry> zipEntries(ZipFile zipFile) {
    final List<ZipEntry> result = new LinkedList<ZipEntry>();
    final Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zipFile.entries();
    while (en.hasMoreElements()) {
        result.add(en.nextElement());
    }/*from w ww  .j  a  v a2s  .  co m*/
    return result;
}

From source file:Main.java

public static String replaceSystemProps(String xml) {
    Properties properties = System.getProperties();
    Enumeration e = properties.propertyNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        String s = "${" + key + "}";
        if (xml.contains(s)) {
            xml = xml.replace(s, properties.getProperty(key));
        }//w w  w  . j  a  v  a  2s  .  c om

    }
    return xml;
}

From source file:Main.java

/** Returns an alphabetically sorted list of the keys. */
public static Vector getSortedKeyList(Hashtable hashtable) {
    Vector result = new Vector();
    Enumeration keys = hashtable.keys();
    while (keys.hasMoreElements()) {
        result.add(keys.nextElement());
    }/*  w w w. ja  v  a2  s.  c o  m*/
    Collections.sort(result, new Comparator() {
        public int compare(Object a, Object b) {
            String textA = a.toString();
            String textB = b.toString();

            return textA.compareToIgnoreCase(textB);
        }
    });

    return result;
}

From source file:Main.java

public static <T> List<T> enumerationToList(Enumeration<T> theEnumeration) {
    ArrayList<T> retVal = new ArrayList<T>();
    while (theEnumeration.hasMoreElements()) {
        retVal.add(theEnumeration.nextElement());
    }//from   w  ww . j a v  a 2 s.c o  m
    return retVal;
}

From source file:PropertiesDemo.java

static void iterateKeys(Locale currentLocale) {

    ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", currentLocale);

    Enumeration bundleKeys = labels.getKeys();

    while (bundleKeys.hasMoreElements()) {
        String key = (String) bundleKeys.nextElement();
        String value = labels.getString(key);
        System.out.println("key = " + key + ", " + "value = " + value);
    }//w w w .  jav a  2  s .  c  om

}

From source file:Main.java

public static List<String> getPackageAllClassName(Context context, String packageName) throws IOException {
    String sourcePath = context.getApplicationInfo().sourceDir;
    List<String> paths = new ArrayList<>();

    if (sourcePath != null) {
        DexFile dexfile = new DexFile(sourcePath);
        Enumeration<String> entries = dexfile.entries();

        while (entries.hasMoreElements()) {
            String element = entries.nextElement();
            if (element.contains(packageName)) {
                paths.add(element);/*  w  ww. j av a2  s  .  c  o m*/
            }
        }
    }

    return paths;
}

From source file:Main.java

public static Vector appendInto(Vector dest, Vector src) {
    Enumeration e = src.elements();
    while (e.hasMoreElements())
        dest.addElement(e.nextElement());
    return dest;//w ww  .  j a v a  2s .  c  o  m
}

From source file:MainClass.java

private static void printEnumeration(Enumeration e, String label) {
    System.out.println("-----" + label + "-----");
    while (e.hasMoreElements()) {
        System.out.println(e.nextElement());
    }/* w  ww . j  a  v a  2  s.co  m*/
}

From source file:Main.java

public static <T> List<T> asList(Enumeration<T> enumeration) {
    List<T> result = new ArrayList<T>();
    while (enumeration.hasMoreElements())
        result.add(enumeration.nextElement());
    return result;
}

From source file:Main.java

public static int getButtonGroupSelectIndex(ButtonGroup bg) {
    if (bg.getButtonCount() <= 0) {
        return -1;
    }//w  ww  .j ava  2s.c om
    Enumeration<AbstractButton> bEnum = bg.getElements();
    for (int i = 0; bEnum.hasMoreElements(); i++) {
        AbstractButton temp = bEnum.nextElement();
        if (temp.isSelected()) {
            return i;
        }

    }
    return -1;
}