@Test public void verify_jar_has_dir_entry() throws Exception { final File baseDir = new File("target/testJarFiles/" + System.currentTimeMillis()); new File(baseDir, "1").mkdirs(); new FileOutputStream(new File(baseDir, "test.txt")).close(); final byte[] jarAsBytes = ClasspathUtils.jarFiles(baseDir.toString()); final File testJar = new File(baseDir, "test.jar"); FileOutputStream fos = new FileOutputStream(testJar); fos.write(jarAsBytes); fos.close(); URLClassLoader urlClassLoader = null; urlClassLoader = new URLClassLoader(new URL[]{testJar.toURI().toURL()}); final URL resource = urlClassLoader.getResource("1"); assertNotNull(resource); }
public static byte[] jarFiles(String path) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JarOutputStream jarOut = new JarOutputStream(bos); int size = addFiles(jarOut, "", new File(path)); if (size == 0) { return null; } jarOut.close(); return bos.toByteArray(); }
ClasspathUtils { public static byte[] jarFiles(String path) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JarOutputStream jarOut = new JarOutputStream(bos); int size = addFiles(jarOut, "", new File(path)); if (size == 0) { return null; } jarOut.close(); return bos.toByteArray(); } }
ClasspathUtils { public static byte[] jarFiles(String path) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JarOutputStream jarOut = new JarOutputStream(bos); int size = addFiles(jarOut, "", new File(path)); if (size == 0) { return null; } jarOut.close(); return bos.toByteArray(); }  }
ClasspathUtils { public static byte[] jarFiles(String path) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JarOutputStream jarOut = new JarOutputStream(bos); int size = addFiles(jarOut, "", new File(path)); if (size == 0) { return null; } jarOut.close(); return bos.toByteArray(); }  static List<String> getStartupClasspath(); static Collection<URL> listCurrentClasspath(); static ClassLoader getNearestSystemClassloader(ClassLoader cl); static Collection<URL> listCurrentClasspath(URLClassLoader classLoader); static byte[] createManifestJar(Manifest manifest); static byte[] createBootstrapperJar(Manifest manifest, Class<?> bootstrapper); static byte[] jarFiles(String path); }
ClasspathUtils { public static byte[] jarFiles(String path) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); JarOutputStream jarOut = new JarOutputStream(bos); int size = addFiles(jarOut, "", new File(path)); if (size == 0) { return null; } jarOut.close(); return bos.toByteArray(); }  static List<String> getStartupClasspath(); static Collection<URL> listCurrentClasspath(); static ClassLoader getNearestSystemClassloader(ClassLoader cl); static Collection<URL> listCurrentClasspath(URLClassLoader classLoader); static byte[] createManifestJar(Manifest manifest); static byte[] createBootstrapperJar(Manifest manifest, Class<?> bootstrapper); static byte[] jarFiles(String path);  }