Iterating over classes in a jar file

Does anyone know a 2-3 line solution for iterating over classes in some kind of Jar file?

(I have a java.net.URL instance in my hand)

thank

+3
source share
2 answers

Access Mailboxes and Banks Using Java Part 1

Access Mailboxes and Banks Using Java Part 2

Here is the code snippet from the first article:

  ZipFile zip = new ZipFile(fileName);

  // Process the zip file. Close it when the block is exited.

  try {
     // Loop through the zip entries and print the name of each one.

     for (Enumeration list = zip.entries(); list.hasMoreElements(); ) {
        ZipEntry entry = (ZipEntry) list.nextElement();
        System.out.println(entry.getName());
     }
  }
  finally {
     zip.close();
  }
+4
source

jar -tf xyz.jar | grep class

Here is the solution . You can create an input stream from a URL instead of a file that uses code.

0
source

Source: https://habr.com/ru/post/1735218/


All Articles