List of usage examples for org.apache.commons.compress.archivers.zip ZipArchiveOutputStream getBytesWritten
public long getBytesWritten()
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); } } }