/**
*
*/
package com.bkdwei.jsPractice.common;
import java.io.File;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
* @author bkd
*
*/
public class CountClass {
public static void main(String[] args) throws ClassNotFoundException, IOException {
URL url = new URL(
“jar: file:/home/bkd/.m2/repository/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3-sources.jar!/”);
URL url1 = new URL(
“jar: file:/home/bkd/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2-sources.jar!/”);
JarURLConnection jarURLConnection = (JarURLConnection) url.openConnection();
JarFile jarFile = jarURLConnection.getJarFile();
Enumeration<JarEntry> jarEntries = jarFile.entries();
int number = 0;
while (jarEntries.hasMoreElements()) {
JarEntry jarEntry = jarEntries.nextElement();
String jarEntryName = jarEntry.getName();
if (jarEntryName.endsWith(“.class”)) {
System.out.println(jarEntryName);
}
number++;
}
System.out.println(number);
}
}