gpt4 book ai didi

org.apache.commons.compress.archivers.zip.ZipArchiveEntry.setCompressedSize()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 09:44:40 49 4
gpt4 key购买 nike

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

ZipArchiveEntry.setCompressedSize介绍

暂无

代码示例

代码示例来源:origin: org.apache.commons/commons-compress

/**
   * Update the original {@link ZipArchiveEntry} with sizes/crc
   * Do not use this methods from threads that did not create the instance itself !
   * @return the zipArchiveEntry that is basis for this request
   */
  public ZipArchiveEntry transferToArchiveEntry(){
    final ZipArchiveEntry entry = zipArchiveEntryRequest.getZipArchiveEntry();
    entry.setCompressedSize(compressedSize);
    entry.setSize(size);
    entry.setCrc(crc);
    entry.setMethod(zipArchiveEntryRequest.getMethod());
    return entry;
  }
}

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * Records whether a Zip64 extra is present and sets the size
 * information from it if sizes are 0xFFFFFFFF and the entry
 * doesn't use a data descriptor.
 */
private void processZip64Extra(final ZipLong size, final ZipLong cSize) {
  final Zip64ExtendedInformationExtraField z64 =
    (Zip64ExtendedInformationExtraField)
    current.entry.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
  current.usesZip64 = z64 != null;
  if (!current.hasDataDescriptor) {
    if (z64 != null // same as current.usesZip64 but avoids NPE warning
        && (cSize.equals(ZipLong.ZIP64_MAGIC) || size.equals(ZipLong.ZIP64_MAGIC)) ) {
      current.entry.setCompressedSize(z64.getCompressedSize().getLongValue());
      current.entry.setSize(z64.getSize().getLongValue());
    } else {
      current.entry.setCompressedSize(cSize.getValue());
      current.entry.setSize(size.getValue());
    }
  }
}

代码示例来源:origin: plutext/docx4j

ze.setCompressedSize(bytes.length);

代码示例来源:origin: org.apache.commons/commons-compress

entry.entry.setCompressedSize(bytesWritten);
entry.entry.setCrc(crc);
entry.entry.setCompressedSize(bytesWritten);
entry.entry.setCrc(crc);

代码示例来源:origin: org.apache.commons/commons-compress

private void readDataDescriptor() throws IOException {
  readFully(wordBuf);
  ZipLong val = new ZipLong(wordBuf);
  if (ZipLong.DD_SIG.equals(val)) {
    // data descriptor with signature, skip sig
    readFully(wordBuf);
    val = new ZipLong(wordBuf);
  }
  current.entry.setCrc(val.getValue());
  // if there is a ZIP64 extra field, sizes are eight bytes
  // each, otherwise four bytes each.  Unfortunately some
  // implementations - namely Java7 - use eight bytes without
  // using a ZIP64 extra field -
  // https://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7073588
  // just read 16 bytes and check whether bytes nine to twelve
  // look like one of the signatures of what could follow a data
  // descriptor (ignoring archive decryption headers for now).
  // If so, push back eight bytes and assume sizes are four
  // bytes, otherwise sizes are eight bytes each.
  readFully(twoDwordBuf);
  final ZipLong potentialSig = new ZipLong(twoDwordBuf, DWORD);
  if (potentialSig.equals(ZipLong.CFH_SIG) || potentialSig.equals(ZipLong.LFH_SIG)) {
    pushback(twoDwordBuf, DWORD, DWORD);
    current.entry.setCompressedSize(ZipLong.getValue(twoDwordBuf));
    current.entry.setSize(ZipLong.getValue(twoDwordBuf, WORD));
  } else {
    current.entry.setCompressedSize(ZipEightByteInteger.getLongValue(twoDwordBuf));
    current.entry.setSize(ZipEightByteInteger.getLongValue(twoDwordBuf, DWORD));
  }
}

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * Throws an exception if the size is unknown for a stored entry
 * that is written to a non-seekable output or the entry is too
 * big to be written without Zip64 extra but the mode has been set
 * to Never.
 */
private void validateSizeInformation(final Zip64Mode effectiveMode)
  throws ZipException {
  // Size/CRC not required if SeekableByteChannel is used
  if (entry.entry.getMethod() == STORED && channel == null) {
    if (entry.entry.getSize() == ArchiveEntry.SIZE_UNKNOWN) {
      throw new ZipException("uncompressed size is required for"
                  + " STORED method when not writing to a"
                  + " file");
    }
    if (entry.entry.getCrc() == ZipArchiveEntry.CRC_UNKNOWN) {
      throw new ZipException("crc checksum is required for STORED"
                  + " method when not writing to a file");
    }
    entry.entry.setCompressedSize(entry.entry.getSize());
  }
  if ((entry.entry.getSize() >= ZIP64_MAGIC
     || entry.entry.getCompressedSize() >= ZIP64_MAGIC)
    && effectiveMode == Zip64Mode.Never) {
    throw new Zip64RequiredException(Zip64RequiredException
                     .getEntryTooBigMessage(entry.entry));
  }
}

代码示例来源:origin: org.apache.commons/commons-compress

ze.setCompressedSize(z64.getCompressedSize().getLongValue());
} else if (hasUncompressedSize) {
  z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize()));

代码示例来源:origin: com.haulmont.reports/reports-core

protected ArchiveEntry newStoredEntry(String name, byte[] data) {
  ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
  zipEntry.setSize(data.length);
  zipEntry.setCompressedSize(zipEntry.getSize());
  CRC32 crc32 = new CRC32();
  crc32.update(data);
  zipEntry.setCrc(crc32.getValue());
  return zipEntry;
}

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected ArchiveEntry newStoredEntry(String name, byte[] data) {
  ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
  zipEntry.setSize(data.length);
  zipEntry.setCompressedSize(zipEntry.getSize());
  CRC32 crc32 = new CRC32();
  crc32.update(data);
  zipEntry.setCrc(crc32.getValue());
  return zipEntry;
}

代码示例来源:origin: com.haulmont.reports/reports-core

protected ArchiveEntry newStoredEntry(String name, byte[] data) {
  ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
  zipEntry.setSize(data.length);
  zipEntry.setCompressedSize(zipEntry.getSize());
  CRC32 crc32 = new CRC32();
  crc32.update(data);
  zipEntry.setCrc(crc32.getValue());
  return zipEntry;
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

private static ArchiveEntry newTailArchive(String name, byte[] tail) {
  ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
  zipEntry.setSize(tail.length);
  zipEntry.setCompressedSize(zipEntry.getSize());
  CRC32 crc32 = new CRC32();
  crc32.update(tail);
  zipEntry.setCrc(crc32.getValue());
  return zipEntry;
}

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected ArchiveEntry newStoredEntry(String name, byte[] data) {
    ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
    zipEntry.setSize(data.length);
    zipEntry.setCompressedSize(zipEntry.getSize());
    CRC32 crc32 = new CRC32();
    crc32.update(data);
    zipEntry.setCrc(crc32.getValue());
    return zipEntry;
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

private static ArchiveEntry newArchive(File file) throws IOException {
  ZipArchiveEntry zipEntry = new ZipArchiveEntry(file.getName());
  zipEntry.setSize(file.length());
  zipEntry.setCompressedSize(zipEntry.getSize());
  zipEntry.setCrc(FileUtils.checksumCRC32(file));
  return zipEntry;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
   * Update the original {@link ZipArchiveEntry} with sizes/crc
   * Do not use this methods from threads that did not create the instance itself !
   * @return the zipArchiveEntry that is basis for this request
   */
  public ZipArchiveEntry transferToArchiveEntry(){
    final ZipArchiveEntry entry = zipArchiveEntryRequest.getZipArchiveEntry();
    entry.setCompressedSize(compressedSize);
    entry.setSize(size);
    entry.setCrc(crc);
    entry.setMethod(zipArchiveEntryRequest.getMethod());
    return entry;
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Records whether a Zip64 extra is present and sets the size
 * information from it if sizes are 0xFFFFFFFF and the entry
 * doesn't use a data descriptor.
 */
private void processZip64Extra(final ZipLong size, final ZipLong cSize) {
  final Zip64ExtendedInformationExtraField z64 =
    (Zip64ExtendedInformationExtraField)
    current.entry.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
  current.usesZip64 = z64 != null;
  if (!current.hasDataDescriptor) {
    if (z64 != null // same as current.usesZip64 but avoids NPE warning
        && (cSize.equals(ZipLong.ZIP64_MAGIC) || size.equals(ZipLong.ZIP64_MAGIC)) ) {
      current.entry.setCompressedSize(z64.getCompressedSize().getLongValue());
      current.entry.setSize(z64.getSize().getLongValue());
    } else {
      current.entry.setCompressedSize(cSize.getValue());
      current.entry.setSize(size.getValue());
    }
  }
}

代码示例来源:origin: org.docx4j/docx4j

ze.setCompressedSize(bytes.length);

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

entry.entry.setCompressedSize(bytesWritten);
entry.entry.setCrc(crc);
entry.entry.setCompressedSize(bytesWritten);
entry.entry.setCrc(crc);

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private void readDataDescriptor() throws IOException {
  readFully(wordBuf);
  ZipLong val = new ZipLong(wordBuf);
  if (ZipLong.DD_SIG.equals(val)) {
    // data descriptor with signature, skip sig
    readFully(wordBuf);
    val = new ZipLong(wordBuf);
  }
  current.entry.setCrc(val.getValue());
  // if there is a ZIP64 extra field, sizes are eight bytes
  // each, otherwise four bytes each.  Unfortunately some
  // implementations - namely Java7 - use eight bytes without
  // using a ZIP64 extra field -
  // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7073588
  // just read 16 bytes and check whether bytes nine to twelve
  // look like one of the signatures of what could follow a data
  // descriptor (ignoring archive decryption headers for now).
  // If so, push back eight bytes and assume sizes are four
  // bytes, otherwise sizes are eight bytes each.
  readFully(twoDwordBuf);
  final ZipLong potentialSig = new ZipLong(twoDwordBuf, DWORD);
  if (potentialSig.equals(ZipLong.CFH_SIG) || potentialSig.equals(ZipLong.LFH_SIG)) {
    pushback(twoDwordBuf, DWORD, DWORD);
    current.entry.setCompressedSize(ZipLong.getValue(twoDwordBuf));
    current.entry.setSize(ZipLong.getValue(twoDwordBuf, WORD));
  } else {
    current.entry.setCompressedSize(ZipEightByteInteger.getLongValue(twoDwordBuf));
    current.entry.setSize(ZipEightByteInteger.getLongValue(twoDwordBuf, DWORD));
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Throws an exception if the size is unknown for a stored entry
 * that is written to a non-seekable output or the entry is too
 * big to be written without Zip64 extra but the mode has been set
 * to Never.
 */
private void validateSizeInformation(final Zip64Mode effectiveMode)
  throws ZipException {
  // Size/CRC not required if SeekableByteChannel is used
  if (entry.entry.getMethod() == STORED && channel == null) {
    if (entry.entry.getSize() == ArchiveEntry.SIZE_UNKNOWN) {
      throw new ZipException("uncompressed size is required for"
                  + " STORED method when not writing to a"
                  + " file");
    }
    if (entry.entry.getCrc() == ZipArchiveEntry.CRC_UNKNOWN) {
      throw new ZipException("crc checksum is required for STORED"
                  + " method when not writing to a file");
    }
    entry.entry.setCompressedSize(entry.entry.getSize());
  }
  if ((entry.entry.getSize() >= ZIP64_MAGIC
     || entry.entry.getCompressedSize() >= ZIP64_MAGIC)
    && effectiveMode == Zip64Mode.Never) {
    throw new Zip64RequiredException(Zip64RequiredException
                     .getEntryTooBigMessage(entry.entry));
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

ze.setCompressedSize(z64.getCompressedSize().getLongValue());
} else if (hasUncompressedSize) {
  z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize()));

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