List<String> files) throws IOException { try (org.apache.tools.zip.ZipFile zf = new org.apache.tools.zip.ZipFile(file, "utf-8")) { Set<String> dirSet = new HashSet<>(); StreamUtils.enumerationAsStream(zf.getEntries()).forEach(ze -> {
private void unzip(File dir, File zipFile) throws IOException { ZipFile zip = new ZipFile(zipFile); @SuppressWarnings("unchecked") Enumeration<ZipEntry> entries = zip.getEntries();
/** * Returns <code>true</code> if the file exists and is signed with * the signature specified, or, if <code>name</code> wasn't * specified, if the file contains a signature. * @param zipFile the zipfile to check * @param name the signature to check (may be killed) * @return true if the file is signed. * @throws IOException on error */ public static boolean isSigned(File zipFile, String name) throws IOException { try (ZipFile jarFile = new ZipFile(zipFile)) { if (null == name) { return StreamUtils.enumerationAsStream(jarFile.getEntries()) .anyMatch(e -> e.getName().startsWith(SIG_START) && e.getName().endsWith(SIG_END)); } name = replaceInvalidChars(name); boolean shortSig = jarFile.getEntry(SIG_START + name.toUpperCase() + SIG_END) != null; boolean longSig = false; if (name.length() > SHORT_SIG_LIMIT) { longSig = jarFile.getEntry( SIG_START + name.substring(0, SHORT_SIG_LIMIT).toUpperCase() + SIG_END) != null; } return shortSig || longSig; } }
/** * fetches information from the named entry inside the archive. */ protected void fetchEntry() { ZipFile z = null; try { z = new ZipFile(getZipfile(), getEncoding()); setEntry(z.getEntry(getName())); } catch (IOException e) { log(e.getMessage(), Project.MSG_DEBUG); throw new BuildException(e); } finally { ZipFile.closeQuietly(z); } }
"Only file provider resources are supported")); try (ZipFile zf = new ZipFile(srcFile, encoding)) { StreamUtils.enumerationAsStream(zf.getEntries()).forEach(entry -> { Resource r = new ZipResource(srcFile, encoding, entry);
int pling = uri.indexOf("!/"); if (uri.startsWith("jar:file") && pling > -1) { zf = new ZipFile(org.apache.tools.ant.launch.Locator .fromJarURI(uri), "UTF-8"); inputStream =
getLocation()); try (ZipFile zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)) { boolean empty = true; Enumeration<ZipEntry> entries = zf.getEntries();
base = fileset.getDir(getProject()); } else if (zfs instanceof ZipFileSet) { zf = new ZipFile(zfs.getSrc(getProject()), encoding);
return getCheckedRef().getInputStream(); final ZipFile z = new ZipFile(getZipfile(), getEncoding()); ZipEntry ze = z.getEntry(getName()); if (ze == null) {
ZipFile zipFile = new ZipFile(zipFilePath, encoding); Enumeration<? extends ZipEntry> entryEnum = zipFile.getEntries(); if (null != entryEnum) {
ZipFile zipFile = new ZipFile(zipFilePath, encoding); Enumeration<? extends ZipEntry> entryEnum = zipFile.getEntries(); if (null != entryEnum) {
private static void readPack() throws Exception { String basePath = "/opt/"; String filename = "/out/zssq-360.apk"; ZipFile file = new ZipFile(basePath + filename); Enumeration<? extends ZipEntry> entries = file.getEntries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); System.out.println(entry.getName()); } }
public static void unzipToDirectory(File file, File destDir) throws IOException { ZipFile zipFile = new ZipFile(file); try { unzipToDirectory(zipFile, destDir); } finally { ZipFile.closeQuietly(zipFile); } }
try { File sourceFile = new File(sourcePath); zipFile = new ZipFile(sourcePath, "gbk"); if ((!sourceFile.exists()) && (sourceFile.length() <= 0)) { throw new Exception("要解压的文件不存在!");
public static boolean unZipWithoutOverWrite(String unZipFileName, String destFileName) { File unzipFile = new File(unZipFileName); if (StringUtils.isBlank(destFileName) || destFileName.trim().length() == 0) destFileName = unzipFile.getParent(); File destFile; ZipFile zipFile = null; try { zipFile = new ZipFile(unzipFile, "GBK"); for (Enumeration entries = zipFile.getEntries(); entries .hasMoreElements();) { ZipEntry entry = (ZipEntry) entries.nextElement(); destFile = new File(destFileName, entry.getName()); unZipFile(destFile, zipFile, entry, false); // 执行解压 } } catch (Exception e) { log.error("解压ZIP文件异常", e); return false; } finally { try { assert zipFile != null; zipFile.close(); } catch (Exception e) { log.error("异常", e); } } return true; }
ZipFile zipFile = null; try { zipFile = new ZipFile(unzipFile, "GBK"); for (Enumeration entries = zipFile.getEntries(); entries .hasMoreElements();) {
ZipFile zf = new ZipFile(zipFile);
private void checkJarContext(String filePath, File file) throws CQLException { ZipFile zipFile = null; try { /* * 检查文件类型是否是zip文件,ANT中会自动进行检查,无需解压缩 */ zipFile = new ZipFile(file, ENCODING, true); } catch (FileNotFoundException e) { CQLException exception = new CQLException(ErrorCode.SEMANTICANALYZE_FILE_NOT_EXISTS, filePath); LOG.error("File does not exists.", exception); throw exception; } catch (IOException e) { CQLException exception = new CQLException(ErrorCode.SEMANTICANALYZE_FILE_NOT_JAR, filePath); LOG.error("File not a jar type.", exception); throw exception; } finally { ZipFile.closeQuietly(zipFile); } }
ZipFile zip = new ZipFile(zipFile); File expandedDir = getExpandedDir(); try {
private void unzip(File dir, File zipFile) throws IOException { ZipFile zip = new ZipFile(zipFile); @SuppressWarnings("unchecked") Enumeration<ZipEntry> entries = zip.getEntries();