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

    return paths;
}

From source file:Main.java

public static void writeToWriter(Enumeration enumList, Writer out) throws IOException {
    while (enumList.hasMoreElements()) {
        out.write(enumList.nextElement().toString());
        out.write(newLine);/*from  ww w  . j a v  a2  s  .c o m*/
    }
    out.flush();
}

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());
    }//w  ww .jav  a  2 s.  c  o  m
    return retVal;
}

From source file:MainClass.java

public static void printDescendents(TreeNode root) {
    System.out.println(root);//  ww  w. ja  va2s  . c o m
    Enumeration children = root.children();
    if (children != null) {
        while (children.hasMoreElements()) {
            printDescendents((TreeNode) children.nextElement());
        }
    }
}

From source file:Main.java

/**
 * Iterates over the given Enumeration <code>e</code> and adds all elements to the given Collection <code>collInOut</code>.
 * @return the same collection that has been passed as collInOut
 *///from w w  w  .j a va2 s .c o  m
public static <E, C extends Collection<E>> C addAll(C collInOut, Enumeration<? extends E> e) {
    while (e.hasMoreElements()) {
        collInOut.add(e.nextElement());
    }
    return collInOut;
}

From source file:Main.java

/**
 * Create a list from an enumeration//  ww  w .j  av a 2 s  .c  om
 * 
 * @param e the enumeration
 * @return the list
 */
public static List list(Enumeration e) {
    ArrayList result = new ArrayList();
    while (e.hasMoreElements())
        result.add(e.nextElement());
    return result;
}

From source file:Main.java

/**
 * Fix properties keys./*from  www. j  a v  a  2 s .c  o m*/
 *
 * @param prop
 *            the prop
 */
public static void fixPropertiesKeys(final Properties prop) {
    final Enumeration<Object> keys = prop.keys();
    while (keys.hasMoreElements()) {
        final String currentKey = (String) keys.nextElement();
        final String fixedKey = fixPropertyKey(currentKey);
        final String value = prop.getProperty(currentKey);
        prop.remove(currentKey);
        prop.setProperty(fixedKey, value);
    }
}

From source file:Main.java

public static <T> List<T> read(Enumeration<T> e) {
    List<T> list = new ArrayList<>();
    while (e.hasMoreElements()) {
        list.add(e.nextElement());/*from  w  w w  . j ava  2s . c  om*/
    }
    return list;
}

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());// www . j  a  v a 2 s .c om
    }
    return result;
}

From source file:Main.java

public static <T> List<T> asList(Enumeration<T> e) {
    List<T> l = new LinkedList<T>();

    while (e.hasMoreElements()) {
        l.add(e.nextElement());/*w  w  w  . j  a v a  2  s  .  com*/
    }

    return l;
}