List of utility methods to do Jar Zip File
void | addJarToClasspath(File jarFile) add Jar To Classpath try { URL url = jarFile.toURI().toURL(); URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class<?> urlClass = URLClassLoader.class; Method method = urlClass.getDeclaredMethod("addURL", new Class<?>[] { URL.class }); method.setAccessible(true); method.invoke(urlClassLoader, new Object[] { url }); } catch (Throwable t) { ... |
void | addToJar(File source, JarOutputStream jarOutput) add To Jar BufferedInputStream in = null; try { if (source.isDirectory()) { String name = source.getPath().replace("\\", "/"); if (!name.isEmpty()) { if (!name.endsWith("/")) name += "/"; JarEntry entry = new JarEntry(name); ... |
void | addToJar(JarOutputStream target, String pathInsideJar, File fentry) add To Jar JarEntry entry = new JarEntry(pathInsideJar); entry.setTime(fentry.lastModified()); target.putNextEntry(entry); BufferedInputStream in = new BufferedInputStream(new FileInputStream(fentry)); byte[] buffer = new byte[1024]; while (true) { int count = in.read(buffer); if (count == -1) { ... |