gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-18 04:20:40 26 4
gpt4 key购买 nike

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

ZipEntry.getTime介绍

[英]Gets the last modification time of this ZipEntry.
[中]获取此ZipEntry的上次修改时间。

代码示例

代码示例来源:origin: spotbugs/spotbugs

@Override
  public long getLastModified() {
    long time = zipEntry.getTime();
    if (time < 0) {
      return 0;
    }
    return time;
  }
}

代码示例来源:origin: konsoletyper/teavm

@Override
public long lastModified() {
  return entry.getTime();
}

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

try{
  ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), 0);
  ZipFile zf = new ZipFile(ai.sourceDir);
  ZipEntry ze = zf.getEntry("classes.dex");
  long time = ze.getTime();
  String s = SimpleDateFormat.getInstance().format(new java.util.Date(time));
  zf.close();
}catch(Exception e){
}

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

public void setTime(ZipEntry newInstance, ZipEntry oldInstance) {
 long time = oldInstance.getTime();
 if (time != -1) {
  newInstance.setTime(time);
 }
}

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

/**
 * Description of the Method
 */
protected void expandFile( final File srcF, final File dir )
  throws Exception
{
  ZipInputStream zis = null;
  try
  {
    // code from WarExpand
    zis = new ZipInputStream( new FileInputStream( srcF ) );
    for ( ZipEntry ze = zis.getNextEntry(); ze != null; ze = zis.getNextEntry() )
    {
      extractFile( srcF, dir, zis, ze.getName(), new Date( ze.getTime() ), ze.isDirectory() );
    }
    // log("expand complete", Project.MSG_VERBOSE);
    zis.close();
    zis = null;
  }
  catch ( IOException ioe )
  {
    throw new Exception( "Error while expanding " + srcF.getPath(), ioe );
  }
  finally
  {
    IOUtil.close( zis );
  }
}

代码示例来源:origin: spotbugs/spotbugs

private void scanForNextEntry() {
    while (nextEntry == null) {
      if (!zipEntryEnumerator.hasMoreElements()) {
        return;
      }
      ZipEntry zipEntry = zipEntryEnumerator.nextElement();
      if (!zipEntry.isDirectory()) {
        addLastModifiedTime(zipEntry.getTime());
        nextEntry = new ZipFileCodeBaseEntry(ZipFileCodeBase.this, zipEntry);
        break;
      }
    }
  }
};

代码示例来源:origin: spotbugs/spotbugs

ZipInputStreamCodeBaseEntry build(ZipInputStream zis, ZipEntry ze) throws IOException {
  long sz = ze.getSize();
  ByteArrayOutputStream out;
  if (sz < 0 || sz > Integer.MAX_VALUE) {
    out = new ByteArrayOutputStream();
  } else {
    out = new ByteArrayOutputStream((int) sz);
  }
  IO.copy(zis, out);
  byte[] bytes = out.toByteArray();
  addLastModifiedTime(ze.getTime());
  return new ZipInputStreamCodeBaseEntry(this, ze, bytes);
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

IOUtils.copyBytes(zip, out, BUFFER_SIZE);
if (!file.setLastModified(entry.getTime())) {
 numOfFailedLastModifiedSet++;

代码示例来源:origin: Sable/soot

public boolean selectCompilationUnit(String canonicalName) throws IOException {
  ZipFile zipFile = null;
  boolean success = false;
  try{
    zipFile = new ZipFile(file);
    String name = canonicalName.replace('.', '/'); // ZipFiles always use '/' as separator
    name = name + fileSuffix();
    if(set.contains(name)) {
      ZipEntry zipEntry = zipFile.getEntry(name);
      if(zipEntry != null && !zipEntry.isDirectory()) {
        is = new ZipEntryInputStreamWrapper(zipFile,zipEntry);
        age = zipEntry.getTime();
        pathName = zipFile.getName();
        relativeName = name + fileSuffix();
        fullName = canonicalName;
        success = true;
      }
    }
  } finally {
    if(zipFile != null && !success)
      zipFile.close();
  }
  return success;
}

代码示例来源:origin: spotbugs/spotbugs

byte data[] = out.toByteArray();
contents.put(name, data);
lastModified.put(name, e.getTime());

代码示例来源:origin: spotbugs/spotbugs

long timestamp = ze.getTime();
Long oldTimestamp = copied.get(name);
if (oldTimestamp == null) {

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

long time1 = e1.getTime();
long time2 = e2.getTime();
if (time1 != -1 && time2 != -1 && time1 != time2) {
 log.trace("Entry '" + path + "' time changed (" + new Date(time1) + " vs " + new Date(time2) + ").");

代码示例来源:origin: spotbugs/spotbugs

public ZipEntry newZipEntry(ZipEntry ze) {
  ZipEntry ze2 = new ZipEntry(ze.getName());
  ze2.setComment(ze.getComment());
  ze2.setTime(ze.getTime());
  ze2.setExtra(ze.getExtra());
  return ze2;
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldPreserveFileTimestampWhileGeneratingTheZipFile() throws Exception {
  File file = temporaryFolder.newFile("foo.txt");
  file.setLastModified(1297989100000L); // Set this to any date in the past which is greater than the epoch
  File zip = zipUtil.zip(file, temporaryFolder.newFile("foo.zip"), Deflater.DEFAULT_COMPRESSION);
  ZipFile actualZip = new ZipFile(zip.getAbsolutePath());
  ZipEntry entry = actualZip.getEntry(file.getName());
  assertThat(entry.getTime(), is(file.lastModified()));
}

代码示例来源:origin: org.apache.ant/ant

outputEntry.setTime(inputEntry.getTime());
outputEntry.setExtra(inputEntry.getExtra());
outputEntry.setComment(inputEntry.getComment());
outputEntry.setTime(inputEntry.getTime());
if (compression) {
  outputEntry.setMethod(ZipEntry.DEFLATED);

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

/**
 * Transforms the zip entry given as an input stream and ZipEntry metadata.
 * The result is written to a ZipOutputStream
 *   * @param in input stream of the entry contents
 * @param zipEntry zip entry metadata
 * @param out output stream to write transformed entry
 *
 * @throws IOException if anything goes wrong
 */
public void transform(InputStream in, ZipEntry zipEntry, ZipOutputStream out) throws IOException {
 byte[] bytes = IOUtils.toByteArray(in);
 bytes = transform(zipEntry, bytes);
 ByteSource source;
 if (preserveTimestamps()) {
  source = new ByteSource(zipEntry.getName(), bytes, zipEntry.getTime());
 }
 else {
  source = new ByteSource(zipEntry.getName(), bytes);
 }
 ZipEntrySourceZipEntryTransformer.addEntry(source, out);
}

代码示例来源:origin: spring-projects/spring-loaded

newZipEntry.setTime(ze.getTime());//LastModifiedTime());

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

/**
 * Copy entry with another name.
 *
 * @param original - zipEntry to copy
 * @param newName - new entry name, optional, if null, ogirinal's entry
 * @return copy of the original entry, but with the given name
 */
static ZipEntry copy(ZipEntry original, String newName) {
 ZipEntry copy = new ZipEntry(newName == null ? original.getName() : newName);
 if (original.getCrc() != -1) {
  copy.setCrc(original.getCrc());
 }
 if (original.getMethod() != -1) {
  copy.setMethod(original.getMethod());
 }
 if (original.getSize() >= 0) {
  copy.setSize(original.getSize());
 }
 if (original.getExtra() != null) {
  copy.setExtra(original.getExtra());
 }
 copy.setComment(original.getComment());
 copy.setTime(original.getTime());
 return copy;
}

代码示例来源:origin: jphp-group/jphp

private static ArrayMemory zipEntryToArray(ZipEntry zipEntry) {
  final ArrayMemory result = new ArrayMemory();
  result.refOfIndex("name").assign(zipEntry.getName());
  result.refOfIndex("crc").assign(zipEntry.getCrc());
  result.refOfIndex("size").assign(zipEntry.getSize());
  result.refOfIndex("compressedSize").assign(zipEntry.getCompressedSize());
  result.refOfIndex("time").assign(zipEntry.getTime());
  result.refOfIndex("method").assign(zipEntry.getMethod());
  result.refOfIndex("comment").assign(zipEntry.getComment());
  result.refOfIndex("directory").assign(zipEntry.isDirectory());
  return result;
}

代码示例来源:origin: robovm/robovm

if (currentEntry.getTime() == -1) {
  currentEntry.setTime(System.currentTimeMillis());

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