data-collector/src/main/java/se/kth/depclean/experiments/util/JarUtils.java
/**
     * Decompress a jar file in a path to a directory (will be created if it doesn't exists).
     *
     * @param jarFilePath
     * @param destDirectory
     * @throws IOException
     */
Decompress a jar file in a path to a directory (will be created if it doesn't exists).
Decompress a jar file in a path to a directory ( will be created if it doesn ' t exists ) .
public static void decompressJarFile(String destDirectory, String jarFilePath) throws IOException {
        File destDir = new File(destDirectory);
        if (!destDir.exists()) {
           destDir.mkdir();
        }
        JarInputStream jarIn = new JarInputStream(new FileInputStream(jarFilePath));
        JarEntry entry = jarIn.getNextJarEntry();
        while (entry != null) {
            String filePath = destDirectory + "/" + entry.getName();
            if (!entry.isDirectory()) {
                new File(filePath).getParentFile().mkdirs();
                extractFile(jarIn, filePath);
            }/* else {
                System.out.println("New dir: " + filePath);
                // if the entry is a directory, make the directory
                File dir = new File(filePath);
                dir.mkdir();
                System.out.println(dir.canWrite());
            }*/
            jarIn.closeEntry();
            entry = jarIn.getNextJarEntry();
        }
        jarIn.close();
    }
public static void decompressJarFile ( String destDirectory , String jarFilePath ) throws IOException { File destDir = new File ( destDirectory ) ; if ( ! destDir . exists ( ) ) { destDir . mkdir ( ) ; } JarInputStream jarIn = new JarInputStream ( new FileInputStream ( jarFilePath ) ) ; JarEntry entry = jarIn . getNextJarEntry ( ) ; while ( entry != null ) { String filePath = destDirectory + "/" + entry . getName ( ) ; if ( ! entry . isDirectory ( ) ) { new File ( filePath ) . getParentFile ( ) . mkdirs ( ) ; extractFile ( jarIn , filePath ) ; } /* else {
                System.out.println("New dir: " + filePath);
                // if the entry is a directory, make the directory
                File dir = new File(filePath);
                dir.mkdir();
                System.out.println(dir.canWrite());
            }*/ jarIn . closeEntry ( ) ; entry = jarIn . getNextJarEntry ( ) ; } jarIn . close ( ) ; }
Decompress a jar file in a path to a directory (will be created if it doesn't exists).
Decompress a jar file in a path to a directory ( will be created if it doesn ' t exists ) .
// iterates over entries in the jar file // if the entry is a file, extracts it