Scan the jar @throws IOException bad things happen
()
| 48 | * @throws IOException bad things happen |
| 49 | */ |
| 50 | public void scan() throws IOException { |
| 51 | classes.clear(); |
| 52 | FileInputStream fin = new FileInputStream(jar); |
| 53 | ZipInputStream zip = new ZipInputStream(fin); |
| 54 | |
| 55 | for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) { |
| 56 | if (!entry.isDirectory() && entry.getName().endsWith(".class")) { |
| 57 | if (entry.getName().contains("$")) { |
| 58 | continue; |
| 59 | } |
| 60 | |
| 61 | String c = entry.getName().replaceAll("/", ".").replace(".class", ""); |
| 62 | |
| 63 | if (c.startsWith(superPackage)) { |
| 64 | try { |
| 65 | Class<?> clazz = Class.forName(c); |
| 66 | classes.add(clazz); |
| 67 | } catch (ClassNotFoundException e) { |
| 68 | e.printStackTrace(); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | zip.close(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Get the scanned clases |