gpt4 book ai didi

org.apache.tools.zip.ZipOutputStream.setUseZip64()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 17:50:40 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.tools.zip.ZipOutputStream.setUseZip64()方法的一些代码示例,展示了ZipOutputStream.setUseZip64()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipOutputStream.setUseZip64()方法的具体详情如下:
包路径:org.apache.tools.zip.ZipOutputStream
类名称:ZipOutputStream
方法名:setUseZip64

ZipOutputStream.setUseZip64介绍

[英]Whether Zip64 extensions will be used.

When setting the mode to Zip64Mode#Never, #putNextEntry, #closeEntry, #finish or #close may throw a Zip64RequiredException if the entry's size or the total size of the archive exceeds 4GB or there are more than 65536 entries inside the archive. Any archive created in this mode will be readable by implementations that don't support Zip64.

When setting the mode to Zip64Mode#Always, Zip64 extensions will be used for all entries. Any archive created in this mode may be unreadable by implementations that don't support Zip64 even if all its contents would be.

When setting the mode to Zip64Mode#AsNeeded, Zip64 extensions will transparently be used for those entries that require them. This mode can only be used if the uncompressed size of the ZipEntry is known when calling #putNextEntry or the archive is written to a seekable output (i.e. you have used the #ZipOutputStream(java.io.File)) - this mode is not valid when the output stream is not seekable and the uncompressed size is unknown when #putNextEntry is called.

If no entry inside the resulting archive requires Zip64 extensions then Zip64Mode#Never will create the smallest archive. Zip64Mode#AsNeeded will create a slightly bigger archive if the uncompressed size of any entry has initially been unknown and create an archive identical to Zip64Mode#Never otherwise. Zip64Mode#Always will create an archive that is at least 24 bytes per entry bigger than the one Zip64Mode#Never would create.

Defaults to Zip64Mode#AsNeeded unless #putNextEntry is called with an entry of unknown size and data is written to a non-seekable stream - in this case the default is Zip64Mode#Never.
[中]是否将使用Zip64扩展。
将模式设置为Zip64Mode时,如果条目大小或归档文件的总大小超过4GB,或者归档文件中的条目超过65536条,则可能会抛出Zip64RequiredException。在这种模式下创建的任何存档都可以被不支持Zip64的实现读取。
将模式设置为Zip64Mode#Always时,所有条目都将使用Zip64扩展名。不支持Zip64的实现可能无法读取在此模式下创建的任何存档,即使其所有内容都将被删除。
根据需要将模式设置为Zip64Mode#时,Zip64扩展将透明地用于需要它们的条目。只有在调用#putNextEntry时已知ZipEntry的未压缩大小,或者将存档写入可查找的输出(即,您使用了#ZipOutputStream(java.io.File))-当输出流不可查找且调用#putNextEntry时未知未压缩大小时,此模式无效。
如果生成的存档中没有条目需要Zip64扩展,那么Zip64Mode#永远不会创建最小的存档。如果任何条目的未压缩大小最初未知,Zip64Mode#根据需要将创建稍大的存档,并创建与Zip64Mode#完全相同的存档。Zip64Mode#总是会创建一个存档,每个条目至少有24字节,比Zip64Mode#永远不会创建的大。
默认为Zip64Mode#根据需要,除非使用未知大小的条目调用#putNextEntry,并将数据写入不可查找的流——在这种情况下,默认为Zip64Mode#Never。

代码示例

代码示例来源:origin: jenkinsci/jenkins

ZipArchiver(OutputStream out) {
  zip = new ZipOutputStream(out);
  zip.setEncoding(System.getProperty("file.encoding"));
  zip.setUseZip64(Zip64Mode.AsNeeded);
}

代码示例来源:origin: org.apache.ant/ant

zOut.setUseZip64(getZip64Mode().getMode());
if (isCompress()) {
  zOut.setMethod(ZipOutputStream.DEFLATED);

代码示例来源:origin: org.apache.ant/ant

? ZipOutputStream.DEFLATED : ZipOutputStream.STORED);
zOut.setLevel(level);
zOut.setUseZip64(zip64Mode.getMode());

代码示例来源:origin: org.gradle/gradle-core

public ZipOutputStream createArchiveOutputStream(File destination) throws IOException {
  ZipOutputStream outStream = new ZipOutputStream(destination);
  try {
    outStream.setUseZip64(zip64Mode);
    outStream.setMethod(entryCompressionMethod);
    return outStream;
  } catch (Exception e) {
    IOUtils.closeQuietly(outStream);
    String message = String.format("Unable to create ZIP output stream for file %s.", destination);
    throw new UncheckedIOException(message, e);
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com