当前位置: 首页>>代码示例>>Java>>正文


Java ZipEntry.STORED属性代码示例

本文整理汇总了Java中java.util.zip.ZipEntry.STORED属性的典型用法代码示例。如果您正苦于以下问题:Java ZipEntry.STORED属性的具体用法?Java ZipEntry.STORED怎么用?Java ZipEntry.STORED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.zip.ZipEntry的用法示例。


在下文中一共展示了ZipEntry.STORED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeEntry

private void writeEntry(ZipFile zf, ZipOutputStream os, ZipEntry ze)
        throws IOException {
    ZipEntry ze2 = new ZipEntry(ze.getName());
    ze2.setMethod(ze.getMethod());
    ze2.setTime(ze.getTime());
    ze2.setComment(ze.getComment());
    ze2.setExtra(ze.getExtra());
    if (ze.getMethod() == ZipEntry.STORED) {
        ze2.setSize(ze.getSize());
        ze2.setCrc(ze.getCrc());
    }
    os.putNextEntry(ze2);
    writeBytes(zf, ze, os);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:JarSigner.java

示例2: writeEntry

private long writeEntry(InputStream zis, ZipOutputStream output, ZipEntry newEntry) throws IOException {
  // FIXME: is there a better way to do this, so that the whole input
  // stream isn't in memory at once?
  final byte[] contents = IOUtils.toByteArray(zis);
  final CRC32 checksum = new CRC32();
  checksum.update(contents);
  if (newEntry.getMethod() == ZipEntry.STORED) {
    newEntry.setSize(contents.length);
    newEntry.setCrc(checksum.getValue());
  }
  output.putNextEntry(newEntry);
  output.write(contents, 0, contents.length);
  return checksum.getValue();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:14,代码来源:ZipUpdater.java

示例3: copyUnknownFiles

private void copyUnknownFiles(File appDir, ZipOutputStream outputFile, Map<String, String> files)
        throws IOException {
    File unknownFileDir = new File(appDir, UNK_DIRNAME);

    // loop through unknown files
    for (Map.Entry<String,String> unknownFileInfo : files.entrySet()) {
        File inputFile = new File(unknownFileDir, unknownFileInfo.getKey());
        if (inputFile.isDirectory()) {
            continue;
        }

        ZipEntry newEntry = new ZipEntry(unknownFileInfo.getKey());
        int method = Integer.parseInt(unknownFileInfo.getValue());
        LOGGER.fine(String.format("Copying unknown file %s with method %d", unknownFileInfo.getKey(), method));
        if (method == ZipEntry.STORED) {
            newEntry.setMethod(ZipEntry.STORED);
            newEntry.setSize(inputFile.length());
            newEntry.setCompressedSize(-1);
            BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(inputFile));
            CRC32 crc = BrutIO.calculateCrc(unknownFile);
            newEntry.setCrc(crc.getValue());
        } else {
            newEntry.setMethod(ZipEntry.DEFLATED);
        }
        outputFile.putNextEntry(newEntry);

        BrutIO.copy(inputFile, outputFile);
        outputFile.closeEntry();
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:30,代码来源:Androlib.java


注:本文中的java.util.zip.ZipEntry.STORED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。