@Test public final void testProcessOneZip() throws Exception { APIFormatter target = new APIFormatter() { @Override protected void doClass(Class<?> c) throws IOException { ++nClasses; x = c; } }; target.processOneZip(fileName); assertEquals(x, GetAndInvokeMethod.class); assertEquals(1, nClasses); System.out.println("Pass!"); }
public void processOneZip(String fileName) throws IOException { List<ZipEntry> entries = new ArrayList<ZipEntry>(); try (ZipFile zipFile = new ZipFile(new File(fileName))) { Enumeration<? extends ZipEntry> all = (Enumeration<? extends ZipEntry>) zipFile.entries(); while (all.hasMoreElements()) { ZipEntry zipEntry = all.nextElement(); entries.add(zipEntry); } } catch (ZipException zz) { throw new FileNotFoundException(zz.toString() + fileName); } Collections.sort(entries, new Comparator<ZipEntry>() { public int compare(ZipEntry o1, ZipEntry o2) { return o1.getName().compareTo(o2.getName()); } }); for (ZipEntry zipEntry : entries) { String zipName = zipEntry.getName(); if (zipEntry.isDirectory()) { continue; } if (!zipName.endsWith(".class")) { continue; } String className = zipName.replace('/', '.'). substring(0, zipName.length() - 6); Class<?> c = null; try { c = Class.forName(className); } catch (ClassNotFoundException ex) { System.err.println("Error: " + ex); } doClass(c); } }
APIFormatter { public void processOneZip(String fileName) throws IOException { List<ZipEntry> entries = new ArrayList<ZipEntry>(); try (ZipFile zipFile = new ZipFile(new File(fileName))) { Enumeration<? extends ZipEntry> all = (Enumeration<? extends ZipEntry>) zipFile.entries(); while (all.hasMoreElements()) { ZipEntry zipEntry = all.nextElement(); entries.add(zipEntry); } } catch (ZipException zz) { throw new FileNotFoundException(zz.toString() + fileName); } Collections.sort(entries, new Comparator<ZipEntry>() { public int compare(ZipEntry o1, ZipEntry o2) { return o1.getName().compareTo(o2.getName()); } }); for (ZipEntry zipEntry : entries) { String zipName = zipEntry.getName(); if (zipEntry.isDirectory()) { continue; } if (!zipName.endsWith(".class")) { continue; } String className = zipName.replace('/', '.'). substring(0, zipName.length() - 6); Class<?> c = null; try { c = Class.forName(className); } catch (ClassNotFoundException ex) { System.err.println("Error: " + ex); } doClass(c); } } }
APIFormatter { public void processOneZip(String fileName) throws IOException { List<ZipEntry> entries = new ArrayList<ZipEntry>(); try (ZipFile zipFile = new ZipFile(new File(fileName))) { Enumeration<? extends ZipEntry> all = (Enumeration<? extends ZipEntry>) zipFile.entries(); while (all.hasMoreElements()) { ZipEntry zipEntry = all.nextElement(); entries.add(zipEntry); } } catch (ZipException zz) { throw new FileNotFoundException(zz.toString() + fileName); } Collections.sort(entries, new Comparator<ZipEntry>() { public int compare(ZipEntry o1, ZipEntry o2) { return o1.getName().compareTo(o2.getName()); } }); for (ZipEntry zipEntry : entries) { String zipName = zipEntry.getName(); if (zipEntry.isDirectory()) { continue; } if (!zipName.endsWith(".class")) { continue; } String className = zipName.replace('/', '.'). substring(0, zipName.length() - 6); Class<?> c = null; try { c = Class.forName(className); } catch (ClassNotFoundException ex) { System.err.println("Error: " + ex); } doClass(c); } }  }
APIFormatter { public void processOneZip(String fileName) throws IOException { List<ZipEntry> entries = new ArrayList<ZipEntry>(); try (ZipFile zipFile = new ZipFile(new File(fileName))) { Enumeration<? extends ZipEntry> all = (Enumeration<? extends ZipEntry>) zipFile.entries(); while (all.hasMoreElements()) { ZipEntry zipEntry = all.nextElement(); entries.add(zipEntry); } } catch (ZipException zz) { throw new FileNotFoundException(zz.toString() + fileName); } Collections.sort(entries, new Comparator<ZipEntry>() { public int compare(ZipEntry o1, ZipEntry o2) { return o1.getName().compareTo(o2.getName()); } }); for (ZipEntry zipEntry : entries) { String zipName = zipEntry.getName(); if (zipEntry.isDirectory()) { continue; } if (!zipName.endsWith(".class")) { continue; } String className = zipName.replace('/', '.'). substring(0, zipName.length() - 6); Class<?> c = null; try { c = Class.forName(className); } catch (ClassNotFoundException ex) { System.err.println("Error: " + ex); } doClass(c); } }  void processOneZip(String fileName); }
APIFormatter { public void processOneZip(String fileName) throws IOException { List<ZipEntry> entries = new ArrayList<ZipEntry>(); try (ZipFile zipFile = new ZipFile(new File(fileName))) { Enumeration<? extends ZipEntry> all = (Enumeration<? extends ZipEntry>) zipFile.entries(); while (all.hasMoreElements()) { ZipEntry zipEntry = all.nextElement(); entries.add(zipEntry); } } catch (ZipException zz) { throw new FileNotFoundException(zz.toString() + fileName); } Collections.sort(entries, new Comparator<ZipEntry>() { public int compare(ZipEntry o1, ZipEntry o2) { return o1.getName().compareTo(o2.getName()); } }); for (ZipEntry zipEntry : entries) { String zipName = zipEntry.getName(); if (zipEntry.isDirectory()) { continue; } if (!zipName.endsWith(".class")) { continue; } String className = zipName.replace('/', '.'). substring(0, zipName.length() - 6); Class<?> c = null; try { c = Class.forName(className); } catch (ClassNotFoundException ex) { System.err.println("Error: " + ex); } doClass(c); } }  void processOneZip(String fileName);  }