當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。