gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-16 18:22:40 27 4
gpt4 key购买 nike

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

ZipArchiveOutputStream.writeCounted介绍

[英]Write bytes to output or random access file.
[中]将字节写入输出或随机访问文件。

代码示例

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

private void writeCentralDirectoryInChunks() throws IOException {
  final int NUM_PER_WRITE = 1000;
  final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(70 * NUM_PER_WRITE);
  int count = 0;
  for (final ZipArchiveEntry ze : entries) {
    byteArrayOutputStream.write(createCentralFileHeader(ze));
    if (++count > NUM_PER_WRITE){
      writeCounted(byteArrayOutputStream.toByteArray());
      byteArrayOutputStream.reset();
      count = 0;
    }
  }
  writeCounted(byteArrayOutputStream.toByteArray());
}

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

/**
 * Writes the central file header entry.
 * @param ze the entry to write
 * @throws IOException on error
 * @throws Zip64RequiredException if the archive's size exceeds 4
 * GByte and {@link Zip64Mode #setUseZip64} is {@link
 * Zip64Mode#Never}.
 */
protected void writeCentralFileHeader(final ZipArchiveEntry ze) throws IOException {
  final byte[] centralFileHeader = createCentralFileHeader(ze);
  writeCounted(centralFileHeader);
}

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

writeCounted(EOCD_SIG);
writeCounted(ZERO);
writeCounted(ZERO);
writeCounted(num);
writeCounted(num);
writeCounted(ZipLong.getBytes(Math.min(cdLength, ZIP64_MAGIC)));
writeCounted(ZipLong.getBytes(Math.min(cdOffset, ZIP64_MAGIC)));
writeCounted(ZipShort.getBytes(dataLen));
streamCompressor.writeCounted(data.array(), data.arrayOffset(), dataLen);

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

/**
 * Writes the data descriptor entry.
 * @param ze the entry to write
 * @throws IOException on error
 */
protected void writeDataDescriptor(final ZipArchiveEntry ze) throws IOException {
  if (!usesDataDescriptor(ze.getMethod(), false)) {
    return;
  }
  writeCounted(DD_SIG);
  writeCounted(ZipLong.getBytes(ze.getCrc()));
  if (!hasZip64Extra(ze)) {
    writeCounted(ZipLong.getBytes(ze.getCompressedSize()));
    writeCounted(ZipLong.getBytes(ze.getSize()));
  } else {
    writeCounted(ZipEightByteInteger.getBytes(ze.getCompressedSize()));
    writeCounted(ZipEightByteInteger.getBytes(ze.getSize()));
  }
}

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

private void writeLocalFileHeader(final ZipArchiveEntry ze, final boolean phased) throws IOException {
  final boolean encodable = zipEncoding.canEncode(ze.getName());
  final ByteBuffer name = getName(ze);
  if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER) {
    addUnicodeExtraFields(ze, encodable, name);
  }
  final long localHeaderStart = streamCompressor.getTotalBytesWritten();
  final byte[] localHeader = createLocalFileHeader(ze, name, encodable, phased, localHeaderStart);
  metaData.put(ze, new EntryMetaData(localHeaderStart, usesDataDescriptor(ze.getMethod(), phased)));
  entry.localDataStart = localHeaderStart + LFH_CRC_OFFSET; // At crc offset
  writeCounted(localHeader);
  entry.dataStart = streamCompressor.getTotalBytesWritten();
}

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

private void writeCentralDirectoryInChunks() throws IOException {
  final int NUM_PER_WRITE = 1000;
  final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(70 * NUM_PER_WRITE);
  int count = 0;
  for (final ZipArchiveEntry ze : entries) {
    byteArrayOutputStream.write(createCentralFileHeader(ze));
    if (++count > NUM_PER_WRITE){
      writeCounted(byteArrayOutputStream.toByteArray());
      byteArrayOutputStream.reset();
      count = 0;
    }
  }
  writeCounted(byteArrayOutputStream.toByteArray());
}

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

/**
 * Writes the central file header entry.
 * @param ze the entry to write
 * @throws IOException on error
 * @throws Zip64RequiredException if the archive's size exceeds 4
 * GByte and {@link Zip64Mode #setUseZip64} is {@link
 * Zip64Mode#Never}.
 */
protected void writeCentralFileHeader(final ZipArchiveEntry ze) throws IOException {
  final byte[] centralFileHeader = createCentralFileHeader(ze);
  writeCounted(centralFileHeader);
}

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

writeCounted(EOCD_SIG);
writeCounted(ZERO);
writeCounted(ZERO);
writeCounted(num);
writeCounted(num);
writeCounted(ZipLong.getBytes(Math.min(cdLength, ZIP64_MAGIC)));
writeCounted(ZipLong.getBytes(Math.min(cdOffset, ZIP64_MAGIC)));
writeCounted(ZipShort.getBytes(dataLen));
streamCompressor.writeCounted(data.array(), data.arrayOffset(), dataLen);

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

/**
 * Writes the data descriptor entry.
 * @param ze the entry to write
 * @throws IOException on error
 */
protected void writeDataDescriptor(final ZipArchiveEntry ze) throws IOException {
  if (!usesDataDescriptor(ze.getMethod(), false)) {
    return;
  }
  writeCounted(DD_SIG);
  writeCounted(ZipLong.getBytes(ze.getCrc()));
  if (!hasZip64Extra(ze)) {
    writeCounted(ZipLong.getBytes(ze.getCompressedSize()));
    writeCounted(ZipLong.getBytes(ze.getSize()));
  } else {
    writeCounted(ZipEightByteInteger.getBytes(ze.getCompressedSize()));
    writeCounted(ZipEightByteInteger.getBytes(ze.getSize()));
  }
}

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

private void writeLocalFileHeader(final ZipArchiveEntry ze, final boolean phased) throws IOException {
  final boolean encodable = zipEncoding.canEncode(ze.getName());
  final ByteBuffer name = getName(ze);
  if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER) {
    addUnicodeExtraFields(ze, encodable, name);
  }
  final long localHeaderStart = streamCompressor.getTotalBytesWritten();
  final byte[] localHeader = createLocalFileHeader(ze, name, encodable, phased, localHeaderStart);
  metaData.put(ze, new EntryMetaData(localHeaderStart, usesDataDescriptor(ze.getMethod(), phased)));
  entry.localDataStart = localHeaderStart + LFH_CRC_OFFSET; // At crc offset
  writeCounted(localHeader);
  entry.dataStart = streamCompressor.getTotalBytesWritten();
}

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