JarUtils { public static void extract(File jarSourceFile, File targetDirectory) throws IOException { extract(jarSourceFile, targetDirectory, null); }  static JarFile toJarFile(URL jarURL); @Nonnull static String resolveRelativePath(URL jarURL); @Nonnull static String resolveJarAbsolutePath(URL jarURL); @Nonnull static List<JarEntry> filter(JarFile jarFile, JarEntryFilter jarEntryFilter); static JarEntry findJarEntry(URL jarURL); static void extract(File jarSourceFile, File targetDirectory); static void extract(File jarSourceFile, File targetDirectory, JarEntryFilter jarEntryFilter); static void extract(JarFile jarFile, File targetDirectory, JarEntryFilter jarEntryFilter); static void extract(URL jarResourceURL, File targetDirectory, JarEntryFilter jarEntryFilter);  }
@Test public void testExtract() throws IOException { Set<String> classPaths = ClassPathUtils.getBootstrapClassPaths(); for (String classPath : classPaths) { File jarFile = new File(classPath); if (jarFile.exists()) { JarUtils.extract(jarFile, targetDirectory); break; } } }
@Test public void testExtractWithURL() throws IOException { URL resourceURL = ClassLoaderUtils.getResource(classLoader, ClassLoaderUtils.ResourceType.PACKAGE, "org.apache.commons.lang3"); JarUtils.extract(resourceURL, targetDirectory, new JarEntryFilter() { @Override public boolean accept(JarEntry filteredObject) { return !filteredObject.isDirectory(); } }); }