- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.util.zip.ZipException
类的一些代码示例,展示了ZipException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipException
类的具体详情如下:
包路径:java.util.zip.ZipException
类名称:ZipException
[英]This runtime exception is thrown by ZipFile and ZipInputStream when the file or stream is not a valid zip file.
[中]当文件或流不是有效的zip文件时,ZipFile和ZipInputStream会引发此运行时异常。
代码示例来源:origin: cmusphinx/sphinx4
URI newURI = new URI(absoluteLocation);
ZipFile zipFile =
new ZipFile(new File(newURI));
ZipEntry entry = zipFile.getEntry(file);
if (entry != null) {
stream = zipFile.getInputStream(entry);
zipFile.close();
} catch (URISyntaxException use) {
use.printStackTrace();
throw new ZipException("URISyntaxException: " +
use.getMessage());
代码示例来源:origin: org.apache.ant/ant
return;
try (ZipFile zipf = new ZipFile(f)) {
Enumeration<? extends ZipEntry> entries = zipf.entries();
while (entries.hasMoreElements()) {
ZipEntry inputEntry = entries.nextElement();
String inputEntryName = inputEntry.getName();
int index = inputEntryName.indexOf("META-INF");
if (ex.getMessage().contains("duplicate")) {
try (InputStream in = zipf.getInputStream(inputEntry)) {
int len = buffer.length;
int count = -1;
代码示例来源:origin: spotbugs/spotbugs
super(codeBaseLocator);
try {
this.zipFile = new ZipFile(file);
setLastModifiedTime(file.lastModified());
} catch (IOException e) {
file.length()));
ZipException e2 = new ZipException("Error opening zip file " + file + " of " + file.length() + " bytes");
e2.initCause(e);
throw e2;
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Potentially reads more bytes to fill the inflater's buffer and
* reads from it.
*/
private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException {
int read = 0;
do {
if (inf.needsInput()) {
final int l = fill();
if (l > 0) {
current.bytesReadFromStream += buf.limit();
} else if (l == -1) {
return -1;
} else {
break;
}
}
try {
read = inf.inflate(buffer, offset, length);
} catch (final DataFormatException e) {
throw (IOException) new ZipException(e.getMessage()).initCause(e);
}
} while (read == 0 && inf.needsInput());
return read;
}
代码示例来源:origin: org.apache.commons/commons-compress
switch(onUnparseableData.getKey()) {
case UnparseableExtraField.THROW_KEY:
throw new ZipException("bad extra field starting at "
+ start + ". Block length of "
+ length + " bytes exceeds remaining"
throw new ZipException("unknown UnparseableExtraField key: "
+ onUnparseableData.getKey());
throw (ZipException) new ZipException("Failed to parse corrupt ZIP extra field of type "
+ Integer.toHexString(headerId.getValue())).initCause(aiobe);
throw (ZipException) new ZipException(ie.getMessage()).initCause(ie);
代码示例来源:origin: org.apache.cxf/cxf-common-utilities
private List<String> load(File jarFile) throws IOException {
List<String> jarContents = new ArrayList<String>();
try {
ZipFile zf = new ZipFile(jarFile);
for (Enumeration e = zf.entries(); e.hasMoreElements();) {
ZipEntry ze = (ZipEntry) e.nextElement();
if (ze.isDirectory()) {
continue;
}
jarContents.add(ze.getName());
}
} catch (NullPointerException e) {
System.out.println("done.");
} catch (ZipException ze) {
ze.printStackTrace();
}
return jarContents;
}
代码示例来源:origin: biz.aQute.bnd/bndlib
public static ZipFile build(Jar jar, File file, Pattern pattern) throws ZipException, IOException {
try {
ZipFile zip = new ZipFile(file);
nextEntry: for (Enumeration< ? extends ZipEntry> e = zip.entries(); e.hasMoreElements();) {
ZipEntry entry = e.nextElement();
if (pattern != null) {
Matcher m = pattern.matcher(entry.getName());
if (!m.matches())
continue nextEntry;
}
if (!entry.isDirectory()) {
jar.putResource(entry.getName(), new ZipResource(zip, entry), true);
}
}
return zip;
}
catch (ZipException ze) {
throw new ZipException("The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: "
+ ze.getMessage());
}
catch (FileNotFoundException e) {
throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath());
}
}
代码示例来源:origin: net.open-esb.core/manage
/**
* Unzips a file.
*
* @param zpFile File to be unzipped
* @throws IOException if error trying to read entry.
* @throws java.util.zip.ZipException if error trying to read zip file.
*/
public void unZip (File zpFile) throws IOException, ZipException
{
if (!zpFile.getName ().endsWith (".zip"))
{
throw new ZipException ("Not a zip file? " + zpFile.getName ());
}
// process all entries in that JAR file
ZipFile zp = new ZipFile (zpFile);
Enumeration all = zp.entries ();
while (all.hasMoreElements ())
{
getEntry (zp, ((ZipEntry) (all.nextElement ())));
}
zp.close ();
}
代码示例来源:origin: deathmarine/Luyten
Set<String> history = new HashSet<String>();
int tick = 0;
while (ent.hasMoreElements() && !cancel) {
bar.setValue(++tick);
JarEntry entry = ent.nextElement();
if (!mass.contains(entry.getName()))
continue;
if (!ze.getMessage().contains("duplicate")) {
throw ze;
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
private Jar buildFromZip(File file) throws IOException {
try {
zipFile = new ZipFile(file);
for (ZipEntry entry : Iterables.iterable(zipFile.entries())) {
if (entry.isDirectory()) {
continue;
}
putResource(entry.getName(), new ZipResource(zipFile, entry), true);
}
return this;
} catch (ZipException e) {
IO.close(zipFile);
ZipException ze = new ZipException(
"The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: " + e.getMessage());
ze.initCause(e);
throw ze;
} catch (FileNotFoundException e) {
IO.close(zipFile);
throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath(), e);
} catch (IOException e) {
IO.close(zipFile);
throw e;
}
}
代码示例来源:origin: TechnicPack/LauncherCore
public static boolean extractFile(File zip, File output, String fileName) throws IOException, InterruptedException {
if (!zip.exists() || fileName == null) {
return false;
}
ZipFile zipFile = null;
try {
zipFile = new ZipFile(zip);
ZipEntry entry = zipFile.getEntry(fileName);
if (entry == null) {
Utils.getLogger().log(Level.WARNING, "File " + fileName + " not found in " + zip.getAbsolutePath());
return false;
}
File outputFile = new File(output, entry.getName());
if (outputFile.getParentFile() != null) {
outputFile.getParentFile().mkdirs();
}
unzipEntry(zipFile, zipFile.getEntry(fileName), outputFile);
return true;
} catch (ZipException e) {
e.printStackTrace();
throw new ZipException("Error extracting file " + zip.getName());
} catch (IOException e) {
Utils.getLogger().log(Level.WARNING, "Error extracting file " + fileName + " from " + zip.getAbsolutePath());
return false;
} finally {
if (zipFile != null) {
zipFile.close();
}
}
}
代码示例来源:origin: robovm/robovm
entry = getEntry(entry.getName());
if (entry == null) {
return null;
throwZipException("Local File Header", localMagic);
throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
} else {
rafStream.endOffset = rafStream.offset + entry.compressedSize;
int bufSize = Math.max(1024, (int) Math.min(entry.getSize(), 65535L));
return new ZipInflaterInputStream(rafStream, new Inflater(true), bufSize, entry);
代码示例来源:origin: robovm/robovm
throw new ZipException("File too short to be a zip file: " + raf.length());
final int headerMagic = Integer.reverseBytes(raf.readInt());
if (headerMagic != LOCSIG) {
throw new ZipException("Not a zip archive");
throw new ZipException("End Of Central Directory signature not found");
throw new ZipException("Spanned archives not supported");
byte[] hdrBuf = new byte[CENHDR]; // Reuse the same buffer for each entry.
for (int i = 0; i < numEntries; ++i) {
ZipEntry newEntry = new ZipEntry(hdrBuf, bufferedStream);
if (newEntry.localHeaderRelOffset >= centralDirOffset) {
throw new ZipException("Local file header offset is after central directory");
String entryName = newEntry.getName();
if (entries.put(entryName, newEntry) != null) {
throw new ZipException("Duplicate entry name: " + entryName);
代码示例来源:origin: org.apache.curator/curator-framework
Inflater inflater = acquireInflater();
try {
inflater.setInput(gzippedDataBytes, headerSize, compressedDataSize);
CRC32 crc = new CRC32();
int offset = 0;
while (true)
numDecompressedBytes = inflater.inflate(result, offset, result.length - offset);
} catch (DataFormatException e) {
String s = e.getMessage();
throw new ZipException(s != null ? s : "Invalid ZLIB data format");
crc.update(result, offset, numDecompressedBytes);
offset += numDecompressedBytes;
if ( inflater.finished() || inflater.needsDictionary() )
else if ( numDecompressedBytes == 0 && inflater.needsInput() )
throw new ZipException("Corrupt GZipped data");
if ( inflater.getRemaining() != 0 )
throw new ZipException("Expected just one GZip block, without garbage in the end");
if ( checksum != (int) crc.getValue() || numUncompressedBytes != offset )
throw new ZipException("Corrupt GZIP trailer");
代码示例来源:origin: org.apache.ant/ant
byte[] tmp = new byte[length - WORD];
System.arraycopy(data, offset + WORD, tmp, 0, length - WORD);
crc.reset();
crc.update(tmp);
long realChecksum = crc.getValue();
if (givenChecksum != realChecksum) {
throw new ZipException("bad CRC checksum "
+ Long.toHexString(givenChecksum)
+ " instead of "
代码示例来源:origin: blynkkk/blynk-server
private void addZipEntryAndWrite(ZipOutputStream zipStream,
String onePinFileName, byte[] onePinDataCsv) throws IOException {
ZipEntry zipEntry = new ZipEntry(onePinFileName);
try {
zipStream.putNextEntry(zipEntry);
zipStream.write(onePinDataCsv);
zipStream.closeEntry();
} catch (ZipException zipException) {
String message = zipException.getMessage();
if (message != null && message.contains("duplicate")) {
log.warn("Duplicate zip entry {}. Wrong report configuration.", onePinFileName);
} else {
log.error("Error compressing report file.", message);
throw zipException;
}
} catch (IOException e) {
log.error("Error compressing report file.", e.getMessage());
throw e;
}
}
代码示例来源:origin: org.apache.curator/curator-framework
private static int doReadHeader(ByteBuffer gzippedData) throws IOException {
if ( gzippedData.getChar() != GZIP_MAGIC )
throw new ZipException("Not in GZip format");
throw new ZipException("Unsupported compression method");
CRC32 crc = new CRC32();
crc.update(gzippedData.array(), 0, gzippedData.position());
if ( gzippedData.getChar() != (char) crc.getValue() )
throw new ZipException("Corrupt GZIP header");
代码示例来源:origin: cmusphinx/sphinx4
stream = new ZipOutputStream(new BufferedOutputStream(fos));
ZipEntry entry = new ZipEntry(file);
((ZipOutputStream) stream).putNextEntry(entry);
} catch (URISyntaxException use) {
use.printStackTrace();
throw new ZipException("URISyntaxException: " +
use.getMessage());
代码示例来源:origin: robovm/robovm
Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
if (inf.finished() || currentEntry == null) {
return -1;
lastRead += toRead;
inRead += toRead;
crc.update(buffer, byteOffset, toRead);
return toRead;
if (inf.needsInput()) {
fill();
if (len > 0) {
read = inf.inflate(buffer, byteOffset, byteCount);
} catch (DataFormatException e) {
throw new ZipException(e.getMessage());
if (read == 0 && inf.finished()) {
return -1;
crc.update(buffer, byteOffset, read);
return read;
代码示例来源:origin: robovm/robovm
private void readAndVerifyDataDescriptor(int inB, int out) throws IOException {
if (hasDD) {
Streams.readFully(in, hdrBuf, 0, EXTHDR);
int sig = Memory.peekInt(hdrBuf, 0, ByteOrder.LITTLE_ENDIAN);
if (sig != (int) EXTSIG) {
throw new ZipException(String.format("unknown format (EXTSIG=%x)", sig));
}
currentEntry.crc = ((long) Memory.peekInt(hdrBuf, EXTCRC, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL;
currentEntry.compressedSize = ((long) Memory.peekInt(hdrBuf, EXTSIZ, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL;
currentEntry.size = ((long) Memory.peekInt(hdrBuf, EXTLEN, ByteOrder.LITTLE_ENDIAN)) & 0xffffffffL;
}
if (currentEntry.crc != crc.getValue()) {
throw new ZipException("CRC mismatch");
}
if (currentEntry.compressedSize != inB || currentEntry.size != out) {
throw new ZipException("Size mismatch");
}
}
我有这个命令: 7z e -oD:\Data\ODS_Source\* D:\Data\DATA_DROP\Source.zip 这导致 D:\Data\ODS_Source\Source\. 我需要
我正在尝试让 Ionic zip 将 zip 文件内的文件夹提取到指定的根目录中。我的问题是里面的zip文件是“zipfile.zip\some_folder\”。我想将“some_folder”中的
我试图让 Ionic zip 将 zip 文件中的文件夹提取到指定的根目录中。我的问题是里面的 zip 文件是“zipfile.zip\some_folder\”。我想将“some_folder”中的
题目 监听服务器端口,得到题目如下: 源码解析 主函数 主函数中是题目界面的逻辑,对应于用户的选择做出相应的操作,其中需要注意的是选项2,解压操作需要获得root权
我有许多需要分发给用户的zip文件,其中约有130个。每个zip文件都包含许多相似的文本,html,xml和jpg文件。压缩文件总计146兆字节;解压缩后,其内容总计551mb。 我想将所有这些文件以
我正在使用 javascript zip.js图书馆。我到处搜索,但找不到将多个文件添加到 zip 的示例。 这是我的代码,但它生成了一个“损坏的”zip。 var len = results.row
在 C# 中,我使用的是 DotNetZip我有一个名为“innerZip.zip”的 zip,其中包含一些数据,和另一个名为“outerZip.zip”的 zip,其中包含 innerZip。我为什
当我使用 library(xlsx) 中的 write.xlsx 时,控制台中会出现以下内容: Note: zip::zip() is deprecated, please use zip::zipr
如果我因为问“非编程”问题而被拒绝,我不会太惊讶,但也许有人知道...... 我正在使用 WinXP 的内置“发送到压缩(zipped)文件夹”功能压缩我的 subversion 沙箱的内容,并惊讶地
我在 Elixir 中有一个二进制字符串,它由压缩字节组成,我想放气并从中提取“真实数据”: iex(93)> data > 我不确定如何解压缩这些数据。到目前为止,我已经: 浏览了 Official
有没有一种方法可以创建一个 zip 文件并强制它在命令行中包含数据描述符部分? 最佳答案 在 Github ( https://github.com/adamhathcock/sharpcompres
我已经有 PBDT.csj and RDK.csj使用此 ( https://www.blackberry.com/SignedKeys/codesigning.html ) 链接进行代码签名处理后的
我研究了几天,发现我们可以将一个包含一些内容的文件添加到 zip 文件中,然后再次压缩它。然后注释将被添加到 zip 文件中,但我不知道该文件到底是什么,所以任何人都知道向 zip(压缩)文件添加注释
我想知道如何找到 zip 文件的压缩级别。 7z 和 winzip 制作的 Zip 文件具有不同的级别评级,因此我想将其中的一些映射到其他工具中的相应级别。 store level 或 level 0
到目前为止,对于Zip文件的Mime类型,我已经看到: 应用程序/八位字节流 multipart / x-zip 应用程序/ zip 应用程序/ zip压缩的 应用程序/ x-zip压缩的 我想我的问
我已经在 google 上搜索、在 wiki 上搜索并阅读了 ZIP 的 RFC,但找不到有关 ZIP 中使用的确切算法的任何信息。 我找到了有关 ZIP == TAR + GZIP 的信息 但是,我
我有这些自解压 zip 文件,我正试图在 2008/7 机器上远程解压这些文件。但它们是以 .exe 的方式出现的,它需要用户双击并选择提取位置。 在 WinZip 支持网站上,他们说要使用/auto
这是我在这里的第一个问题,请耐心等待。 我的目标是在 C# 中创建一个基本的 .zip 存档。我已经尝试使用 .NET 的内置 GZipStream 类并设法实现了这一点,但是我遇到了一个问题,我无法
能否为压缩文件中的压缩文件创建 java.nio.file.FileSystem? 如果是这样,URI 是什么样的? 如果没有,我想我将不得不退回到使用 ZipInputStream。 我正在尝试递归
我想在 here 安装 scala我很关心下载哪一个:zip 还是 tgz。它们之间有什么区别,用例是什么? 最佳答案 它们是不同的archive formats .使用它们是因为它可以节省带宽并且因
我是一名优秀的程序员,十分优秀!