get Jar Entries - Java Reflection

Java examples for Reflection:Jar

Description

get Jar Entries

Demo Code


//package com.java2s;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class Main {
    public static ArrayList getJarEntries(JarFile jarFile, String directory) {
        Enumeration enumeration = jarFile.entries();
        ArrayList<JarEntry> nets = new ArrayList();
        directory = directory + System.getProperty("file.separator");

        while (enumeration.hasMoreElements()) {
            JarEntry je = (JarEntry) enumeration.nextElement();
            String s = je.toString();
            if ((s.indexOf(directory) > -1)
                    && (s.length() > directory.length())) {
                nets.add(je);/*w  w w.  j ava 2  s.  c  o  m*/
            }
        }
        return nets;
    }
}

Related Tutorials