ZipUtils { public static void getResources(ZipFile zip, Pattern filter, Consumer<InputStream> consumer) throws IOException { Enumeration<? extends ZipEntry> zipEntries = zip.entries(); while (zipEntries.hasMoreElements()) { ZipEntry zipEntry = zipEntries.nextElement(); final String name = zipEntry.getName(); if (filter.matcher(name).matches()) { try (InputStream in = zip.getInputStream(zipEntry)) { consumer.accept(in); } } } } private  ZipUtils(); static ZipOutputStream stream(Path zip); static void add(ZipOutputStream out, Path f); static void add(ZipOutputStream out, Path f, Path rootPath); static Collection<String> listEntries(File zip); static Collection<String> listEntries(InputStream in); static void unzip(File zip, File targetDir); static void unzip(InputStream in, File targetDir); static void getResources(ZipFile zip, Pattern filter, Consumer<InputStream> consumer); static boolean isZipFile(File file);  }
@Test public void testGetResources() throws Exception { URL testJar = ZipUtilsTest.class.getResource("/che/che.jar"); @SuppressWarnings("unchecked") Consumer<InputStream> consumer = mock(Consumer.class); ZipUtils.getResources( new ZipFile(testJar.getFile()), Pattern.compile(".*[ verify(consumer, times(2)).accept(any(InputStream.class)); }