gpt4 book ai didi

java.util.zip.ZipOutputStream.setComment()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 23:22:40 26 4
gpt4 key购买 nike

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

ZipOutputStream.setComment介绍

[英]Sets the comment associated with the file being written. See ZipFile#getComment.
[中]设置与正在写入的文件关联的注释。请参见ZipFile#getComment。

代码示例

代码示例来源:origin: Tencent/tinker

/**
 * zip list of file
 *
 * @param resFileList file(dir) list
 * @param zipFile     output zip file
 * @throws IOException
 */
public static void zipFiles(Collection<File> resFileList, File zipFile, String comment) throws IOException {
  ZipOutputStream zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile), TypedValue.BUFFER_SIZE));
  for (File resFile : resFileList) {
    if (resFile.exists()) {
      zipFile(resFile, zipout, "");
    }
  }
  if (comment != null) {
    zipout.setComment(comment);
  }
  zipout.close();
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

public void setComment(String comment) {
  if (out != null) {
    out.setComment(ExportConstants.ZIP_HEADER + "\r\n" + comment);
  }
}

代码示例来源:origin: open-eid/digidoc4j

/**
 * @param comment comment
 */
public void writeContainerComment(String comment) {
 logger.debug("Writing container comment: " + comment);
 zipOutputStream.setComment(comment);
}

代码示例来源:origin: info.magnolia/magnolia-4-5-migration

@Override
public ZipOutputStream getZippedReport(OutputStream out) {
  this.singleHTML = false; // i.e. zipped set of HTML files
  this.zipReport = new ZipOutputStream(out);
  this.zipReport.setComment("Magnolia migration report.");
  generateReport();
  try {
    this.zipReport.putNextEntry(new ZipEntry("index.html"));
    this.zipReport.write(this.htmlReport.getBytes());
  } catch (IOException e) {
    log.error("Cannot put the main entry [index.html] into ZIP report: "+e.getMessage());
    log.debug("Cannot put the main entry [index.html] into ZIP report.", e);
  }
  return this.zipReport;
}

代码示例来源:origin: wutq/AndroidModuleDemo

/**
 * 批量压缩文件(夹)
 *
 * @param resFileList 要压缩的文件(夹)列表
 * @param zipFile     生成的压缩文件
 * @param comment     压缩文件的注释
 * @throws IOException 当压缩过程出错时抛出
 */
public static void zipFiles(Collection<File> resFileList, File zipFile, String comment) throws IOException {
  ZipOutputStream zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile), BUFF_SIZE));
  for (File resFile : resFileList) {
    zipFile(resFile, zipout, "");
  }
  zipout.setComment(comment);
  zipout.close();
}

代码示例来源:origin: abc9070410/JComicDownloader

public static void compress( File source, File destination,
               String comment, int level ) throws IOException
{
  ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( destination ) );
  zos.setComment( comment );
  zos.setLevel( level );
  compress( zos, source.getParent(), source );
  zos.flush();
  zos.close();
}

代码示例来源:origin: stackoverflow.com

public void write(File[] files, String commment) throws IOException {
  FileOutputStream fos = new FileOutputStream(PATH + FILE);
  JarOutputStream jos = new JarOutputStream(fos, manifest);
  BufferedOutputStream bos = new BufferedOutputStream(jos);
  jos.setComment(commment);
  for (File f : files) {
    print("Writing file: " + f.toString());
    BufferedReader br = new BufferedReader(new FileReader(f));
    jos.putNextEntry(new JarEntry(f.getName()));
    int c;
    while ((c = br.read()) != -1) {
      bos.write(c);
    }
    br.close();
    bos.flush();
  }
  bos.close();
//  JarOutputStream jor = new JarOutputStream(new FileOutputStream(PATH + FILE), manifest);

}

代码示例来源:origin: com.orientechnologies/orientdb-core

public static void compressFiles(final String folderName, final String[] entryNames, final OutputStream output,
  final OCommandOutputListener iOutput, final int compressionLevel) throws IOException {
 final ZipOutputStream zos = new ZipOutputStream(output);
 zos.setComment("OrientDB Backup executed on " + new Date());
 try {
  zos.setLevel(compressionLevel);
  for (String entryName : entryNames)
   addFile(zos, folderName + "/" + entryName, entryName, iOutput);
 } finally {
  zos.close();
 }
}

代码示例来源:origin: com.orientechnologies/orientdb-core

public static void compressFile(final String folderName, final String entryName, final OutputStream output,
  final OCommandOutputListener iOutput, final int compressionLevel) throws IOException {
 final ZipOutputStream zos = new ZipOutputStream(output);
 zos.setComment("OrientDB Backup executed on " + new Date());
 try {
  zos.setLevel(compressionLevel);
  addFile(zos, folderName + "/" + entryName, entryName, iOutput);
 } finally {
  zos.close();
 }
}

代码示例来源:origin: Dawish/BriskTVLauncher

/**
 * 批量压缩文件(夹)
 *
 * @param resFileList 要压缩的文件(夹)列表
 * @param zipFile 生成的压缩文件
 * @param comment 压缩文件的注释
 * @throws IOException 当压缩过程出错时抛出
 */
public static void zipFiles(Collection<File> resFileList, File zipFile, String comment)
    throws IOException {
  ZipOutputStream zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(
      zipFile), BUFF_SIZE));
  for (File resFile : resFileList) {
    zipFile(resFile, zipout, "");
  }
  zipout.setComment(comment);
  zipout.close();
}

代码示例来源:origin: com.tencent.tinker/tinker-patch-lib

/**
 * zip list of file
 *
 * @param resFileList file(dir) list
 * @param zipFile     output zip file
 * @throws IOException
 */
public static void zipFiles(Collection<File> resFileList, File zipFile, String comment) throws IOException {
  ZipOutputStream zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile), TypedValue.BUFFER_SIZE));
  for (File resFile : resFileList) {
    if (resFile.exists()) {
      zipFile(resFile, zipout, "");
    }
  }
  if (comment != null) {
    zipout.setComment(comment);
  }
  zipout.close();
}

代码示例来源:origin: com.alibaba/tac-engine

/**
 * compress
 *
 * @param srcFile
 * @param destFile
 * @throws Exception
 */
public static void compress(File srcFile, File destFile) throws Exception {
  // CRC32 check
  CheckedOutputStream cos = new CheckedOutputStream(new FileOutputStream(
    destFile), new CRC32());
  ZipOutputStream zos = new ZipOutputStream(cos);
  zos.setComment(new String("comment"));
  compress(srcFile, zos, BASE_DIR);
  zos.flush();
  zos.close();
}

代码示例来源:origin: com.ebmwebsourcing.commons/commons-jbi

/**
 * This method allows you to create a zip file which contains a set of {@link File} objects given in parameter.
 * 
 * @param zipFile the resulting zip file.
 * @param filesToZip the list of files to add into the zip (key = entry, value = file).
 * @throws IOException might be thrown while interacting with the zip file.
 */
public final File createZipFile( File zipFile, Map<String, File> filesToZip ) throws IOException {
  ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( zipFile ));
  
  // Content
  for( Map.Entry<String, File> entry : filesToZip.entrySet()) {			
    if( entry.getValue().exists())
      addFileToZip( zos, entry.getValue(), entry.getKey());
  }
  
  // Comment
  GregorianCalendar calendar = new GregorianCalendar();
  SimpleDateFormat sdf = new SimpleDateFormat( "MM dd, yyyy 'at' HH:mm:ss" ); 
  String comment = "File generated on " + sdf.format( calendar.getTime());
  zos.setComment( comment );
  
  zos.close();        
  return zipFile;
}

代码示例来源:origin: smuyyh/SprintNBA

/**
 * 批量压缩文件(夹)
 *
 * @param resFileList 要压缩的文件(夹)列表
 * @param zipFile     生成的压缩文件
 * @param comment     压缩文件的注释
 * @param zipListener zipListener
 */
public static void zipFiles(Collection<File> resFileList, File zipFile, String comment, ZipListener zipListener) {
  ZipOutputStream zipout = null;
  try {
    zipout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile), BUFF_SIZE));
    for (File resFile : resFileList) {
      zipFile(resFile, zipout, "", zipListener);
    }
    zipout.setComment(comment);
    zipout.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: alibaba/tac

/**
 * compress
 *
 * @param srcFile
 * @param destFile
 * @throws Exception
 */
public static void compress(File srcFile, File destFile) throws Exception {
  // CRC32 check
  CheckedOutputStream cos = new CheckedOutputStream(new FileOutputStream(
    destFile), new CRC32());
  ZipOutputStream zos = new ZipOutputStream(cos);
  zos.setComment(new String("comment"));
  compress(srcFile, zos, BASE_DIR);
  zos.flush();
  zos.close();
}

代码示例来源:origin: huangweicai/OkLibDemo

/**
 * 批量压缩文件(夹)
 *
 * @param resFileList
 *            要压缩的文件(夹)列表
 * @param zipFile
 *            生成的压缩文件
 * @param comment
 *            压缩文件的注释
 * @throws IOException
 *             当压缩过程出错时抛出
 */
public static void zipFiles(Collection<File> resFileList, File zipFile,
              String comment) throws IOException {
  ZipOutputStream zipout = new ZipOutputStream(new BufferedOutputStream(
      new FileOutputStream(zipFile), BUFF_SIZE));
  for (File resFile : resFileList) {
    zipFile(resFile, zipout, "");
  }
  zipout.setComment(comment);
  zipout.close();
}

代码示例来源:origin: com.github.fosin/cdp-utils

/**
 * zip
 *
 * @throws java.io.IOException if any.
 */
public void zip() throws IOException {
  zos = new ZipOutputStream(target);
  cos = new CheckedOutputStream(zos, new CRC32());
  zos.setComment(comment);
  for(String name:multiInputStream.keySet()){
    ZipEntry ze = new ZipEntry(name);
    zos.putNextEntry(ze);
    InputStream is = multiInputStream.get(name);
    is = new BufferedInputStream(is);
    int readSize = -1;
    byte[] temp = new byte[BUFFER_SIZE];
    while((readSize = is.read(temp, 0 , BUFFER_SIZE)) != -1){
      cos.write(temp, 0, readSize);
    }
  }
}

代码示例来源:origin: de.micromata.jak/JavaAPIforKml

public boolean marshalAsKmz(
  @NotNull
  String name, Kml... additionalFiles)
  throws IOException
{
  ZipOutputStream out = new ZipOutputStream(new FileOutputStream(name));
  out.setComment("KMZ-file created with Java API for KML. Visit us: http://code.google.com/p/javaapiforkml/");
  this.addKmzFile(this, out, true);
  for (Kml kml: additionalFiles) {
    this.addKmzFile(kml, out, false);
  }
  out.close();
  missingNameCounter = 1;
  return false;
}

代码示例来源:origin: micromata/javaapiforkml

public boolean marshalAsKmz(
  @NotNull
  String name, Kml... additionalFiles)
  throws IOException
{
  ZipOutputStream out = new ZipOutputStream(new FileOutputStream(name));
  out.setComment("KMZ-file created with Java API for KML. Visit us: http://code.google.com/p/javaapiforkml/");
  this.addKmzFile(this, out, true);
  for (Kml kml: additionalFiles) {
    this.addKmzFile(kml, out, false);
  }
  out.close();
  missingNameCounter = 1;
  return false;
}

代码示例来源:origin: arhs/sd-dss

private void storeZipComment(final ASiCParameters asicParameters, final ZipOutputStream outZip, final String toSignDocumentName) {
  if (asicParameters.isZipComment() && DSSUtils.isNotEmpty(toSignDocumentName)) {
    outZip.setComment("mimetype=" + getMimeTypeBytes(asicParameters));
  }
}

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