/** * Extracts all files from a given JAR file to a given target directory. * * @param jarFile * The given JAR file. * @param targetDir * The given target directory. * @return Total number of bytes extracted. * @throws IOException * If any I/O exception occurred. */ public static long extractFilesFromJar(JarFile jarFile, File targetDir) throws IOException { return extractFilesFromJar(jarFile, targetDir, null); }
/** * Extracts all specified input PEARs to their corresponding folders inside the output root * folder. Returns the total size (bytes) of extracted files. * * @return The total size of extracted files. * @throws IOException * If any I/O exception occurred during extraction. */ private long extractInputPears() throws IOException { long totalSize = 0; for (int i = 0; i < _inpPearFiles.length; i++) { JarFile pearFile = new JarFile(_inpPearFiles[i]); totalSize += FileUtil.extractFilesFromJar(pearFile, _outDlgRootDirs[i]); } return totalSize; }
/** * Extracts all files in a given JAR directory (including all its subdirectories) from a given JAR * file to a given target directory. * * @param jarFile * The given JAR file. * @param dirPath * The given JAR directory. * @param targetDir * The given target directory. * @return Total number of bytes extracted. * @throws IOException * If any I/O exception occurred. */ public static long extractDirectoryFromJar(JarFile jarFile, String dirPath, File targetDir) throws IOException { return extractFilesFromJar(jarFile, targetDir, new DirFileFilter(dirPath, null)); }
/** * Extracts all files that have a given extension from a given JAR file to a given target * directory. To extract files without extension, use <code>null</code> as the * <code>fileExt</code> parameter. * * @param jarFile * The given JAR file. * @param fileExt * The given file extension. * @param targetDir * The given target directory. * @return Total number of bytes extracted. * @throws IOException * If any I/O exception occurred. */ public static long extractFilesWithExtFromJar(JarFile jarFile, String fileExt, File targetDir) throws IOException { return extractFilesFromJar(jarFile, targetDir, new DirFileFilter(null, fileExt)); }
long totalBytes = (fileExt == null) ? FileUtil.extractFilesFromJar(jarFile, targetDir) : // all