gpt4 book ai didi

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

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

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

ZipArchiveEntry.setMethod介绍

[英]Sets the compression method of this entry.
[中]设置此项的压缩方法。

代码示例

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

/**
 * Provides default values for compression method and last
 * modification time.
 */
private void setDefaults(final ZipArchiveEntry entry) {
  if (entry.getMethod() == -1) { // not specified
    entry.setMethod(method);
  }
  if (entry.getTime() == -1) { // not specified
    entry.setTime(System.currentTimeMillis());
  }
}

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

/**
 * Creates a new zip entry with fields taken from the specified zip entry.
 *
 * <p>Assumes the entry represents a directory if and only if the
 * name ends with a forward slash "/".</p>
 *
 * @param entry the entry to get fields from
 * @throws ZipException on error
 */
public ZipArchiveEntry(final java.util.zip.ZipEntry entry) throws ZipException {
  super(entry);
  setName(entry.getName());
  final byte[] extra = entry.getExtra();
  if (extra != null) {
    setExtraFields(ExtraFieldUtils.parse(extra, true,
                       ExtraFieldUtils
                       .UnparseableExtraField.READ));
  } else {
    // initializes extra data to an empty byte array
    setExtra();
  }
  setMethod(entry.getMethod());
  this.size = entry.getSize();
}

代码示例来源: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: plutext/docx4j

ze.setMethod(ZipArchiveOutputStream.STORED);

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

private ZipArchiveEntryRequest createEntry( final ZipArchiveEntry zipArchiveEntry,
                      final InputStreamSupplier inputStreamSupplier ) throws IOException
{
  // if we re-compress the zip files there is no need to look at the input stream
  if ( compressAddedZips )
  {
    return createZipArchiveEntryRequest( zipArchiveEntry, inputStreamSupplier );
  }
  // otherwise we should inspect the first four bites to see if the input stream is zip file or not
  InputStream is = inputStreamSupplier.get();
  byte[] header = new byte[4];
  try
  {
    int read = is.read( header );
    int compressionMethod = zipArchiveEntry.getMethod();
    if ( isZipHeader( header ) ) {
      compressionMethod = ZipEntry.STORED;
    }
    zipArchiveEntry.setMethod( compressionMethod );
    return createZipArchiveEntryRequest( zipArchiveEntry, prependBytesToStream( header, read, is ) );
  }
  catch ( IOException e )
  {
    IOUtil.close( is );
    throw e;
  }
}

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

current.entry.setMethod(ZipShort.getValue(lfhBuf, off));
off += SHORT;

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

ze.setMethod( ZipArchiveEntry.STORED );
ze.setMethod( ZipArchiveEntry.DEFLATED );
zOut.addArchiveEntry( ze, createInputStreamSupplier( new ByteArrayInputStream( bytes ) ), true );

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

if ( zipArchiveEntry.isDirectory() )
  zipArchiveEntry.setMethod( ZipEntry.STORED );
if ( zipArchiveEntry.isDirectory() )
  zipArchiveEntry.setMethod( ZipEntry.STORED );

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

setTime( ze, lastModified );
ze.setMethod( doCompress ? ZipArchiveEntry.DEFLATED : ZipArchiveEntry.STORED );
ze.setUnixMode( UnixStat.FILE_FLAG | mode );

代码示例来源:origin: IQSS/dataverse

private void createDir(final String name) throws IOException, ExecutionException, InterruptedException {
  ZipArchiveEntry archiveEntry = new ZipArchiveEntry(bagName + "/" + name);
  archiveEntry.setMethod(ZipEntry.DEFLATED);
  InputStreamSupplier supp = new InputStreamSupplier() {
    public InputStream get() {
      return new ByteArrayInputStream(("").getBytes());
    }
  };
  addEntry(archiveEntry, supp);
}

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

/**
 * Provides default values for compression method and last
 * modification time.
 */
private void setDefaults(final ZipArchiveEntry entry) {
  if (entry.getMethod() == -1) { // not specified
    entry.setMethod(method);
  }
  if (entry.getTime() == -1) { // not specified
    entry.setTime(System.currentTimeMillis());
  }
}

代码示例来源:origin: IQSS/dataverse

private void createFileFromString(final String relPath, final String content)
    throws IOException, ExecutionException, InterruptedException {
  ZipArchiveEntry archiveEntry = new ZipArchiveEntry(bagName + "/" + relPath);
  archiveEntry.setMethod(ZipEntry.DEFLATED);
  InputStreamSupplier supp = new InputStreamSupplier() {
    public InputStream get() {
      try {
        return new ByteArrayInputStream(content.getBytes("UTF-8"));
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      }
      return null;
    }
  };
  addEntry(archiveEntry, supp);
}

代码示例来源:origin: IQSS/dataverse

private void createFileFromURL(final String relPath, final String uri)
    throws IOException, ExecutionException, InterruptedException {
  ZipArchiveEntry archiveEntry = new ZipArchiveEntry(bagName + "/" + relPath);
  archiveEntry.setMethod(ZipEntry.DEFLATED);
  InputStreamSupplier supp = getInputStreamSupplier(uri);
  addEntry(archiveEntry, supp);
}

代码示例来源:origin: osmlab/atlas

entry.setMethod(level);

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

/**
 * Creates a new zip entry with fields taken from the specified zip entry.
 *
 * <p>Assumes the entry represents a directory if and only if the
 * name ends with a forward slash "/".</p>
 *
 * @param entry the entry to get fields from
 * @throws ZipException on error
 */
public ZipArchiveEntry(final java.util.zip.ZipEntry entry) throws ZipException {
  super(entry);
  setName(entry.getName());
  final byte[] extra = entry.getExtra();
  if (extra != null) {
    setExtraFields(ExtraFieldUtils.parse(extra, true,
                       ExtraFieldUtils
                       .UnparseableExtraField.READ));
  } else {
    // initializes extra data to an empty byte array
    setExtra();
  }
  setMethod(entry.getMethod());
  this.size = entry.getSize();
}

代码示例来源: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: org.docx4j/docx4j

ze.setMethod(ZipArchiveOutputStream.STORED);

代码示例来源:origin: de.unkrig/de-unkrig-commons

@Override public void
writeEntry(
  ArchiveOutputStream                                              archiveOutputStream,
  ArchiveEntry                                                     archiveEntry,
  @Nullable String                                                 name,
  ConsumerWhichThrows<? super OutputStream, ? extends IOException> writeContents
) throws IOException {
  if (!(archiveOutputStream instanceof ZipArchiveOutputStream)) {
    throw new IllegalArgumentException(archiveOutputStream.getClass().getName());
  }
  ZipArchiveEntry nzae = new ZipArchiveEntry(name != null ? name : archiveEntry.getName());
  nzae.setTime(archiveEntry.getLastModifiedDate().getTime());
  if (archiveEntry instanceof ZipArchiveEntry) {
    ZipArchiveEntry zae  = (ZipArchiveEntry) archiveEntry;
    nzae.setComment(zae.getComment());
    nzae.setExternalAttributes(zae.getExternalAttributes());
    nzae.setExtraFields(zae.getExtraFields(true));
    nzae.setGeneralPurposeBit(zae.getGeneralPurposeBit());
    nzae.setInternalAttributes(zae.getInternalAttributes());
    nzae.setMethod(zae.getMethod());
    if (nzae.isDirectory()) {
      nzae.setSize(0);
      nzae.setCrc(0);
    }
  }
  archiveOutputStream.putArchiveEntry(nzae);
  if (!archiveEntry.isDirectory()) writeContents.consume(archiveOutputStream);
  archiveOutputStream.closeArchiveEntry();
}

代码示例来源:origin: de.unkrig.commons/commons-file

@Override public void
writeEntry(
  ArchiveOutputStream                                              archiveOutputStream,
  ArchiveEntry                                                     archiveEntry,
  @Nullable String                                                 name,
  ConsumerWhichThrows<? super OutputStream, ? extends IOException> writeContents
) throws IOException {
  if (!(archiveOutputStream instanceof ZipArchiveOutputStream)) {
    throw new IllegalArgumentException(archiveOutputStream.getClass().getName());
  }
  ZipArchiveEntry nzae = new ZipArchiveEntry(name != null ? name : archiveEntry.getName());
  nzae.setTime(archiveEntry.getLastModifiedDate().getTime());
  if (archiveEntry instanceof ZipArchiveEntry) {
    ZipArchiveEntry zae  = (ZipArchiveEntry) archiveEntry;
    nzae.setComment(zae.getComment());
    nzae.setExternalAttributes(zae.getExternalAttributes());
    nzae.setExtraFields(zae.getExtraFields(true));
    nzae.setGeneralPurposeBit(zae.getGeneralPurposeBit());
    nzae.setInternalAttributes(zae.getInternalAttributes());
    nzae.setMethod(zae.getMethod());
    if (nzae.isDirectory()) {
      nzae.setSize(0);
      nzae.setCrc(0);
    }
  }
  archiveOutputStream.putArchiveEntry(nzae);
  if (!archiveEntry.isDirectory()) writeContents.consume(archiveOutputStream);
  archiveOutputStream.closeArchiveEntry();
}

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

@Override
  public ArchiveEntry buildEntry(ArchiveBase.ResourceWithFlags r) {
    boolean isDir = r.getResource().isDirectory();
    ZipArchiveEntry ent = new ZipArchiveEntry(r.getName());
    ent.setTime(round(r.getResource().getLastModified(), 2000));
    ent.setSize(isDir ? 0 : r.getResource().getSize());
    if (!isDir && r.getCollectionFlags().hasModeBeenSet()) {
      ent.setUnixMode(r.getCollectionFlags().getMode());
    } else if (isDir
          && r.getCollectionFlags().hasDirModeBeenSet()) {
      ent.setUnixMode(r.getCollectionFlags().getDirMode());
    } else if (r.getResourceFlags().hasModeBeenSet()) {
      ent.setUnixMode(r.getResourceFlags().getMode());
    } else {
      ent.setUnixMode(isDir
              ? ArchiveFileSet.DEFAULT_DIR_MODE
              : ArchiveFileSet.DEFAULT_FILE_MODE);
    }
    if (r.getResourceFlags().getZipExtraFields() != null) {
      ent.setExtraFields(r.getResourceFlags()
                .getZipExtraFields());
    }
    if (keepCompression
      && r.getResourceFlags().hasCompressionMethod()) {
      ent.setMethod(r.getResourceFlags()
             .getCompressionMethod());
    }
    return ent;
  }
});

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