Java Utililty Methods Jar Zip File

List of utility methods to do Jar Zip File

Description

The list of methods to do Jar Zip File are organized into topic(s).

Method

voidaddJarToClasspath(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) {
...
voidaddToJar(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);
...
voidaddToJar(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) {
...