Example usage for org.apache.commons.compress.archivers.zip ZipArchiveEntry setTime

List of usage examples for org.apache.commons.compress.archivers.zip ZipArchiveEntry setTime

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.zip ZipArchiveEntry setTime.

Prototype

public void setTime(long time) 

Source Link

Document

Sets the last modification time of the entry.

Usage

From source file:org.mycore.services.zipper.MCRZipServlet.java

@Override
protected void sendCompressedDirectory(MCRPath file, BasicFileAttributes attrs,
        ZipArchiveOutputStream container) throws IOException {
    ZipArchiveEntry entry = new ZipArchiveEntry(getFilename(file) + "/");
    entry.setTime(attrs.lastModifiedTime().toMillis());
    container.putArchiveEntry(entry);/*from w  ww.  jav a 2s  .c  om*/
    container.closeArchiveEntry();
}

From source file:org.mycore.services.zipper.MCRZipServlet.java

@Override
protected void sendCompressedFile(MCRPath file, BasicFileAttributes attrs, ZipArchiveOutputStream container)
        throws IOException {
    ZipArchiveEntry entry = new ZipArchiveEntry(getFilename(file));
    entry.setTime(attrs.lastModifiedTime().toMillis());
    entry.setSize(attrs.size());// w w  w.  ja  v  a 2s  .  co m
    container.putArchiveEntry(entry);
    try {
        Files.copy(file, container);
    } finally {
        container.closeArchiveEntry();
    }
}

From source file:org.mycore.services.zipper.MCRZipServlet.java

@Override
protected void sendMetadataCompressed(String fileName, byte[] content, long lastModified,
        ZipArchiveOutputStream container) throws IOException {
    ZipArchiveEntry entry = new ZipArchiveEntry(fileName);
    entry.setSize(content.length);//from   w  ww.  ja v a2 s.  c  om
    entry.setTime(lastModified);
    container.putArchiveEntry(entry);
    container.write(content);
    container.closeArchiveEntry();
}

From source file:org.springframework.boot.gradle.tasks.bundling.BootZipCopyAction.java

private void prepareEntry(ZipArchiveEntry entry, int unixMode) {
    if (!this.preserveFileTimestamps) {
        entry.setTime(CONSTANT_TIME_FOR_ZIP_ENTRIES);
    }//www . j a  v  a 2s  . co  m
    entry.setUnixMode(unixMode);
}

From source file:org.zuinnote.hadoop.office.format.common.writer.msexcel.internal.EncryptedZipEntrySource.java

public void setInputStream(InputStream is) throws IOException {
    this.tmpFile = TempFile.createTempFile("hadoopoffice-protected", ".zip");

    ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
    FileOutputStream fos = new FileOutputStream(tmpFile);
    ZipArchiveOutputStream zos = new ZipArchiveOutputStream(fos);
    ZipArchiveEntry ze;// w  w w . ja va2 s  . co  m
    while ((ze = (ZipArchiveEntry) zis.getNextEntry()) != null) {
        // rewrite zip entries to match the size of the encrypted data (with padding)
        ZipArchiveEntry zeNew = new ZipArchiveEntry(ze.getName());
        zeNew.setComment(ze.getComment());
        zeNew.setExtra(ze.getExtra());
        zeNew.setTime(ze.getTime());
        zos.putArchiveEntry(zeNew);
        FilterOutputStream fos2 = new FilterOutputStream(zos) {
            // do not close underlyzing ZipOutputStream
            @Override
            public void close() {
            }
        };
        OutputStream nos;
        if (this.ciEncoder != null) { // encrypt if needed
            nos = new CipherOutputStream(fos2, this.ciEncoder);
        } else { // do not encrypt
            nos = fos2;
        }
        IOUtils.copy(zis, nos);
        nos.close();
        if (fos2 != null) {
            fos2.close();
        }
        zos.closeArchiveEntry();

    }
    zos.close();
    fos.close();
    zis.close();
    IOUtils.closeQuietly(is);
    this.zipFile = new ZipFile(this.tmpFile);

}