gpt4 book ai didi

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

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

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

ZipArchiveOutputStream.setMethod介绍

[英]Sets the default compression method for subsequent entries.

Default is DEFLATED.
[中]设置后续条目的默认压缩方法。
违约率下降。

代码示例

代码示例来源:origin: apache/tika

public void writeTo(Map<String, byte[]> parts, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
    ZipArchiveOutputStream zip = new ZipArchiveOutputStream(entityStream);

    zip.setMethod(ZipArchiveOutputStream.STORED);

    for (Map.Entry<String, byte[]> entry : parts.entrySet()) {
      zipStoreBuffer(zip, entry.getKey(), entry.getValue());
    }

    zip.close();
  }
}

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

if ( isCompress() )
  zipArchiveOutputStream.setMethod( ZipArchiveOutputStream.DEFLATED );
  zipArchiveOutputStream.setMethod( ZipArchiveOutputStream.STORED );

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

zipArchiveOutputStream.setEncoding( encoding );
zipArchiveOutputStream.setCreateUnicodeExtraFields( this.getUnicodeExtraFieldPolicy() );
zipArchiveOutputStream.setMethod(
  doCompress ? ZipArchiveOutputStream.DEFLATED : ZipArchiveOutputStream.STORED );

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

public static void writeArchivedLogToStream(File logFile, OutputStream outputStream) throws IOException {
  if (!logFile.exists()) {
    throw new FileNotFoundException();
  }
  File tempFile = File.createTempFile(FilenameUtils.getBaseName(logFile.getName()) + "_log_", ".zip");
  ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(tempFile);
  zipOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED);
  zipOutputStream.setEncoding(ZIP_ENCODING);
  ArchiveEntry archiveEntry = newArchive(logFile);
  zipOutputStream.putArchiveEntry(archiveEntry);
  FileInputStream logFileInput = new FileInputStream(logFile);
  IOUtils.copyLarge(logFileInput, zipOutputStream);
  logFileInput.close();
  zipOutputStream.closeArchiveEntry();
  zipOutputStream.close();
  FileInputStream tempFileInput = new FileInputStream(tempFile);
  IOUtils.copyLarge(tempFileInput, outputStream);
  tempFileInput.close();
  FileUtils.deleteQuietly(tempFile);
}

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

protected byte[] zipContent(Map<String, Object> stringObjectMap) throws IOException {
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(byteArrayOutputStream);
  zipOutputStream.setMethod(ZipArchiveOutputStream.STORED);
  zipOutputStream.setEncoding(ENCODING);
  for (Map.Entry<String, Object> entry : stringObjectMap.entrySet()) {
    byte[] data = (byte[]) entry.getValue();
    ArchiveEntry archiveEntry = newStoredEntry(entry.getKey(), data);
    zipOutputStream.putArchiveEntry(archiveEntry);
    zipOutputStream.write(data);
    zipOutputStream.closeArchiveEntry();
  }
  zipOutputStream.close();
  return byteArrayOutputStream.toByteArray();
}

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

@Override
public byte[] exportEntitiesToZIP(Collection<? extends Entity> entities) {
  String json = entitySerialization.toJson(entities, null, EntitySerializationOption.COMPACT_REPEATED_ENTITIES);
  byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(byteArrayOutputStream);
  zipOutputStream.setMethod(ZipArchiveOutputStream.STORED);
  zipOutputStream.setEncoding(StandardCharsets.UTF_8.name());
  ArchiveEntry singleDesignEntry = newStoredEntry("entities.json", jsonBytes);
  try {
    zipOutputStream.putArchiveEntry(singleDesignEntry);
    zipOutputStream.write(jsonBytes);
    zipOutputStream.closeArchiveEntry();
  } catch (Exception e) {
    throw new RuntimeException("Error on creating zip archive during entities export", e);
  } finally {
    IOUtils.closeQuietly(zipOutputStream);
  }
  return byteArrayOutputStream.toByteArray();
}

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

@Override
public byte[] exportFolder(Folder folder) throws IOException {
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(byteArrayOutputStream);
  zipOutputStream.setMethod(ZipArchiveOutputStream.STORED);
  zipOutputStream.setEncoding(StandardCharsets.UTF_8.name());
  String xml = createXStream().toXML(folder);
  byte[] xmlBytes = xml.getBytes(StandardCharsets.UTF_8);
  ArchiveEntry zipEntryDesign = newStoredEntry("folder.xml", xmlBytes);
  zipOutputStream.putArchiveEntry(zipEntryDesign);
  zipOutputStream.write(xmlBytes);
  try {
    zipOutputStream.closeArchiveEntry();
  } catch (Exception ex) {
    throw new RuntimeException(String.format("Exception occurred while exporting folder %s.",  folder.getName()));
  }
  zipOutputStream.close();
  return byteArrayOutputStream.toByteArray();
}

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

public static void writeArchivedLogTailToStream(File logFile, OutputStream outputStream) throws IOException {
  if (!logFile.exists()) {
    throw new FileNotFoundException();
  }
  ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(outputStream);
  zipOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED);
  zipOutputStream.setEncoding(ZIP_ENCODING);
  byte[] content = getTailBytes(logFile);
  ArchiveEntry archiveEntry = newTailArchive(logFile.getName(), content);
  zipOutputStream.putArchiveEntry(archiveEntry);
  zipOutputStream.write(content);
  zipOutputStream.closeArchiveEntry();
  zipOutputStream.close();
}

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

if (compress)
  zout.setMethod(ZipArchiveOutputStream.DEFLATED);
  zout.setMethod(ZipArchiveOutputStream.STORED);

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

@Override
public byte[] exportReports(Collection<Report> reports) {
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
  ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(byteArrayOutputStream);
  try {
    zipOutputStream.setMethod(ZipArchiveOutputStream.STORED);
    zipOutputStream.setEncoding(ENCODING);
    for (Report report : reports) {
      try {
        byte[] reportBytes = exportReport(report);
        ArchiveEntry singleReportEntry = newStoredEntry(replaceForbiddenCharacters(report.getName()) + ".zip", reportBytes);
        zipOutputStream.putArchiveEntry(singleReportEntry);
        zipOutputStream.write(reportBytes);
        zipOutputStream.closeArchiveEntry();
      } catch (IOException e) {
        throw new ReportingException(String.format("Exception occurred while exporting report [%s]", report.getName()), e);
      }
    }
  } finally {
    IOUtils.closeQuietly(zipOutputStream);
  }
  return byteArrayOutputStream.toByteArray();
}

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

zipOutputStream.setMethod(ZipArchiveOutputStream.STORED);
zipOutputStream.setEncoding(ReportImportExport.ENCODING);

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

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(byteArrayOutputStream);
zipOutputStream.setMethod(ZipArchiveOutputStream.STORED);
zipOutputStream.setEncoding(ENCODING);

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