Example usage for org.apache.commons.compress.archivers.zip ZipArchiveOutputStream getBytesWritten

List of usage examples for org.apache.commons.compress.archivers.zip ZipArchiveOutputStream getBytesWritten

Introduction

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

Prototype

public long getBytesWritten() 

Source Link

Document

Returns the current number of bytes written to this stream.

Usage

From source file:org.xwiki.filemanager.internal.job.PackJob.java

/**
 * Packs a file.//from ww w .  j  a  v a2  s  . co m
 * 
 * @param fileReference the file to add to the ZIP archive
 * @param zip the ZIP archive to add the file to
 * @param pathPrefix the file path
 */
private void packFile(DocumentReference fileReference, ZipArchiveOutputStream zip, String pathPrefix) {
    org.xwiki.filemanager.File file = fileSystem.getFile(fileReference);
    if (file != null && fileSystem.canView(fileReference)) {
        try {
            String path = pathPrefix + file.getName();
            this.logger.info("Packing file [{}]", path);
            zip.putArchiveEntry(new ZipArchiveEntry(path));
            IOUtils.copy(file.getContent(), zip);
            zip.closeArchiveEntry();
            getStatus().setBytesWritten(zip.getBytesWritten());
        } catch (IOException e) {
            this.logger.warn("Failed to pack file [{}].", fileReference, e);
        }
    }
}