本文整理了Java中org.apache.tools.zip.ZipFile.getEntries()
方法的一些代码示例,展示了ZipFile.getEntries()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFile.getEntries()
方法的具体详情如下:
包路径:org.apache.tools.zip.ZipFile
类名称:ZipFile
方法名:getEntries
[英]Returns all entries.
Entries will be returned in the same order they appear within the archive's central directory.
[中]返回所有条目。
条目将按照它们在存档中心目录中出现的顺序返回。
代码示例来源:origin: org.apache.ant/ant
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 -> {
String name = ze.getName();
if (ze.isDirectory()) {
代码示例来源:origin: jenkinsci/jenkins
Enumeration<ZipEntry> entries = zip.getEntries();
代码示例来源:origin: org.apache.ant/ant
/**
* 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;
}
}
代码示例来源:origin: org.apache.ant/ant
StreamUtils.enumerationAsStream(zf.getEntries()).forEach(entry -> {
Resource r = new ZipResource(srcFile, encoding, entry);
String name = entry.getName();
代码示例来源:origin: org.apache.ant/ant
Enumeration<ZipEntry> entries = zf.getEntries();
while (entries.hasMoreElements()) {
ZipEntry ze = entries.nextElement();
代码示例来源:origin: sanluan/PublicCMS
Enumeration<? extends ZipEntry> entryEnum = zipFile.getEntries();
if (null != entryEnum) {
while (entryEnum.hasMoreElements()) {
代码示例来源:origin: sanluan/PublicCMS
Enumeration<? extends ZipEntry> entryEnum = zipFile.getEntries();
if (null != entryEnum) {
while (entryEnum.hasMoreElements()) {
代码示例来源:origin: gradle.plugin.com.bettycc.umengauto/core
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());
}
}
代码示例来源:origin: gradle.plugin.com.bettycc.umengauto/core
private static Map<ZipEntry, byte[]> readZipAllEntry(ZipFile file) throws Exception {
Map<ZipEntry, byte[]> entryMaps = new HashMap<ZipEntry, byte[]>();
Enumeration<? extends ZipEntry> entries = file.getEntries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
int len = -1;
byte[] data = new byte[512];
InputStream istream = file.getInputStream(entry);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while ((len = istream.read(data, 0, 512)) != -1) {
bos.write(data, 0, len);
}
bos.close();
istream.close();
byte[] result = bos.toByteArray();
entryMaps.put(entry, result);
}
return entryMaps;
}
}
代码示例来源:origin: com.github.javahaohao/utils
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;
}
代码示例来源:origin: net.mingsoft/ms-util
for (Enumeration entries = zip.getEntries(); entries.hasMoreElements();) {
ZipEntry entry = (ZipEntry) entries.nextElement();
String zipEntryName = entry.getName();
代码示例来源:origin: qq53182347/liugh-parent
throw new Exception("要解压的文件不存在!");
Enumeration<?> e = zipFile.getEntries();
while (e.hasMoreElements()) {
ZipEntry zipEnt = (ZipEntry) e.nextElement();
代码示例来源:origin: com.github.javahaohao/utils
try {
zipFile = new ZipFile(unzipFile, "GBK");
for (Enumeration entries = zipFile.getEntries(); entries
.hasMoreElements();) {
ZipEntry entry = (ZipEntry) entries.nextElement();
代码示例来源:origin: GaoFeiGit/xutils
ZipFile zf = new ZipFile(zipFile);
for (Enumeration<ZipEntry> ent = zf.getEntries(); ent.hasMoreElements();) {
ZipEntry entry = ent.nextElement();
file = new File(target + entry.getName());
代码示例来源:origin: com.github.javahaohao/utils
zipFile = new ZipFile(srcZipFile);
for (Enumeration entries = zipFile.getEntries(); entries
.hasMoreElements();) {
zipEntry = (ZipEntry) entries.nextElement();
代码示例来源:origin: com.github.tianjing/tgtools.core
Enumeration e = zf.getEntries();
while (e.hasMoreElements()) {
ZipEntry ze2 = (ZipEntry) e.nextElement();
代码示例来源:origin: org.gradle/gradle-core
Enumeration entries = zip.getEntries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
代码示例来源:origin: net.wasdev.wlp.ant/wlp-anttasks
private static void unzipToDirectory(ZipFile zipFile, File destDir) throws IOException {
byte[] buffer = new byte[4096];
Enumeration entries = zipFile.getEntries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
if (entry.isDirectory()) {
File dir = new File(destDir, entry.getName());
InstallUtils.createDirectory(dir);
} else {
File file = new File(destDir, entry.getName());
InstallUtils.createDirectory(file.getParentFile());
OutputStream out = null;
InputStream in = null;
try {
out = new BufferedOutputStream(new FileOutputStream(file));
in = zipFile.getInputStream(entry);
Unzip.copy(in, out, buffer);
} finally {
InstallUtils.close(in);
InstallUtils.close(out);
}
Unzip.setFilePermissions(file, entry);
}
}
}
代码示例来源:origin: org.kantega.openaksess/openaksess-core
List<ZipEntry> entries = Collections.<ZipEntry>list(zipFile.getEntries());
for(ZipEntry entry : entries) {
if (isValidEntry(entry)) {
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
Enumeration<ZipEntry> entries = zip.getEntries();
内容来源于网络,如有侵权,请联系作者删除!