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

x33g5p2x  于2022-02-05 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(100)

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

ZipEntry.setCreationTime介绍

暂无

代码示例

代码示例来源:origin: uber/NullAway

/**
 * Write model jar file with nullability model at DEFAULT_ASTUBX_LOCATION
 *
 * @param outPath Path of output model jar file.
 */
private static void writeModelJAR(String outPath) throws IOException {
 Preconditions.checkArgument(
   outPath.endsWith(MODEL_JAR_SUFFIX), "invalid model file path! " + outPath);
 ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(outPath));
 if (!map_result.isEmpty()) {
  ZipEntry entry = new ZipEntry(DEFAULT_ASTUBX_LOCATION);
  // Set the modification/creation time to 0 to ensure that this jars always have the same
  // checksum
  entry.setTime(0);
  entry.setCreationTime(FileTime.fromMillis(0));
  zos.putNextEntry(entry);
  writeModel(new DataOutputStream(zos));
  zos.closeEntry();
 }
 zos.close();
 LOG(VERBOSE, "Info", "wrote model to: " + outPath);
}

代码示例来源:origin: zeroturnaround/zt-zip

public void setTime(ZipEntry newInstance, ZipEntry oldInstance) {
 {
  FileTime time = oldInstance.getCreationTime();
  if (time != null) {
   newInstance.setCreationTime(time);
  }
 }
 {
  FileTime time = oldInstance.getLastModifiedTime();
  if (time != null) {
   newInstance.setLastModifiedTime(time);
  }
 }
 {
  FileTime time = oldInstance.getLastAccessTime();
  if (time != null) {
   newInstance.setLastAccessTime(time);
  }
 }
}

代码示例来源:origin: com.github.bloodshura/shurax

public void setCreationTime(@Nonnull Instant creationTime) {
  getHandle().setCreationTime(FileTime.from(creationTime));
}

代码示例来源:origin: com.github.bloodshura/ignitium-core

public void setCreationTime(@Nonnull Instant creationTime) {
  getHandle().setCreationTime(FileTime.from(creationTime));
}

代码示例来源:origin: org.lorislab.corn/corn

entry.setCreationTime(FileTime.fromMillis(file.toFile().lastModified()));
entry.setComment("Created by TheCodersCorner");
zipStream.putNextEntry(entry);

代码示例来源:origin: CoffeePartner/capt

/**
 * write ZIP faster without compress!
 */
final void writeTo(ZipOutputStream zos) throws IOException {
  ZipEntry outEntry = new ZipEntry(name);
  CRC32 crc32 = new CRC32();
  crc32.update(bytes);
  outEntry.setCrc(crc32.getValue());
  outEntry.setMethod(ZipEntry.STORED);
  outEntry.setSize(bytes.length);
  outEntry.setCompressedSize(bytes.length);
  outEntry.setLastAccessTime(ZERO);
  outEntry.setLastModifiedTime(ZERO);
  outEntry.setCreationTime(ZERO);
  zos.putNextEntry(outEntry);
  zos.write(bytes);
}

代码示例来源:origin: org.zeroturnaround/zt-zip

public void setTime(ZipEntry newInstance, ZipEntry oldInstance) {
 {
  FileTime time = oldInstance.getCreationTime();
  if (time != null) {
   newInstance.setCreationTime(time);
  }
 }
 {
  FileTime time = oldInstance.getLastModifiedTime();
  if (time != null) {
   newInstance.setLastModifiedTime(time);
  }
 }
 {
  FileTime time = oldInstance.getLastAccessTime();
  if (time != null) {
   newInstance.setLastAccessTime(time);
  }
 }
}

代码示例来源:origin: docbleach/DocBleach

private ZipEntry cloneEntry(ZipEntry entry) {
  ZipEntry newEntry = new ZipEntry(entry.getName());

  newEntry.setTime(entry.getTime());
  if (entry.getCreationTime() != null) {
   newEntry.setCreationTime(entry.getCreationTime());
  }
  if (entry.getLastModifiedTime() != null) {
   newEntry.setLastModifiedTime(entry.getLastModifiedTime());
  }
  if (entry.getLastAccessTime() != null) {
   newEntry.setLastAccessTime(entry.getLastAccessTime());
  }
  newEntry.setComment(entry.getComment());
  newEntry.setExtra(entry.getExtra());

  return newEntry;
 }
}

相关文章