本文整理了Java中org.apache.tools.zip.ZipFile.<init>()
方法的一些代码示例,展示了ZipFile.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFile.<init>()
方法的具体详情如下:
包路径:org.apache.tools.zip.ZipFile
类名称:ZipFile
方法名:<init>
[英]Opens the given file for reading, assuming the platform's native encoding for file names.
[中]打开给定的文件进行读取,假设平台对文件名采用本机编码。
代码示例来源:origin: org.apache.ant/ant
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 -> {
代码示例来源:origin: jenkinsci/jenkins
private void unzip(File dir, File zipFile) throws IOException {
ZipFile zip = new ZipFile(zipFile);
@SuppressWarnings("unchecked")
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
/**
* 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);
}
}
代码示例来源:origin: org.apache.ant/ant
"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);
代码示例来源:origin: org.apache.ant/ant
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 =
代码示例来源:origin: org.apache.ant/ant
getLocation());
try (ZipFile zf = new ZipFile(srcF, encoding, scanForUnicodeExtraFields)) {
boolean empty = true;
Enumeration<ZipEntry> entries = zf.getEntries();
代码示例来源:origin: org.apache.ant/ant
base = fileset.getDir(getProject());
} else if (zfs instanceof ZipFileSet) {
zf = new ZipFile(zfs.getSrc(getProject()), encoding);
代码示例来源:origin: org.apache.ant/ant
return getCheckedRef().getInputStream();
final ZipFile z = new ZipFile(getZipfile(), getEncoding());
ZipEntry ze = z.getEntry(getName());
if (ze == null) {
代码示例来源:origin: sanluan/PublicCMS
ZipFile zipFile = new ZipFile(zipFilePath, encoding);
Enumeration<? extends ZipEntry> entryEnum = zipFile.getEntries();
if (null != entryEnum) {
代码示例来源:origin: sanluan/PublicCMS
ZipFile zipFile = new ZipFile(zipFilePath, encoding);
Enumeration<? extends ZipEntry> entryEnum = zipFile.getEntries();
if (null != entryEnum) {
代码示例来源: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: net.wasdev.wlp.ant/wlp-anttasks
public static void unzipToDirectory(File file, File destDir) throws IOException {
ZipFile zipFile = new ZipFile(file);
try {
unzipToDirectory(zipFile, destDir);
} finally {
ZipFile.closeQuietly(zipFile);
}
}
代码示例来源:origin: qq53182347/liugh-parent
try {
File sourceFile = new File(sourcePath);
zipFile = new ZipFile(sourcePath, "gbk");
if ((!sourceFile.exists()) && (sourceFile.length() <= 0)) {
throw new Exception("要解压的文件不存在!");
代码示例来源: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: com.github.javahaohao/utils
ZipFile zipFile = null;
try {
zipFile = new ZipFile(unzipFile, "GBK");
for (Enumeration entries = zipFile.getEntries(); entries
.hasMoreElements();) {
代码示例来源:origin: GaoFeiGit/xutils
ZipFile zf = new ZipFile(zipFile);
代码示例来源:origin: HuaweiBigData/StreamCQL
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);
}
}
代码示例来源:origin: org.gradle/gradle-core
ZipFile zip = new ZipFile(zipFile);
File expandedDir = getExpandedDir();
try {
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
private void unzip(File dir, File zipFile) throws IOException {
ZipFile zip = new ZipFile(zipFile);
@SuppressWarnings("unchecked")
Enumeration<ZipEntry> entries = zip.getEntries();
内容来源于网络,如有侵权,请联系作者删除!