public void finishSave() throws Docx4JException { try { // Complete the ZIP file // Don't forget to do this or everything will appear // to work, but when you open the zip file you'll get an error // "End-of-central-directory signature not found." zos.close(); } catch (Exception e ) { throw new Docx4JException("Failed to put binary part", e); } }
zos.closeArchiveEntry(); zos.close(); fos.close(); zis.close();
zos.close();
public void writeTo(Map<String, byte[]> parts, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { ZipArchiveOutputStream zip = new ZipArchiveOutputStream(entityStream); zip.setMethod(ZipArchiveOutputStream.STORED); for (Map.Entry<String, byte[]> entry : parts.entrySet()) { zipStoreBuffer(zip, entry.getKey(), entry.getValue()); } zip.close(); } }
outputStream.close();
zipArchiveOutputStream.close();
@Override public void close() throws IOException { if (outputZip != null){ outputZip.closeArchiveEntry(); outputZip.close(); } outputZip = null; }
public void writeTo( ZipArchiveOutputStream targetStream ) throws IOException, ExecutionException, InterruptedException { metaInfDir.writeTo( targetStream ); manifest.writeTo( targetStream ); directories.writeTo( targetStream ); synchronousEntries.writeTo( targetStream ); parallelScatterZipCreator.writeTo( targetStream ); long startAt = System.currentTimeMillis(); targetStream.close(); zipCloseElapsed = System.currentTimeMillis() - startAt; metaInfDir.close(); manifest.close(); directories.close(); synchronousEntries.close(); }
byte[] zip(byte[] data, String filename) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipArchiveOutputStream zos = new ZipArchiveOutputStream(bos); ZipArchiveEntry entry = new ZipArchiveEntry(filename); entry.setSize(data.length); zos.putArchiveEntry(entry); zos.write(data); zos.closeArchiveEntry(); zos.close(); bos.close(); return bos.toByteArray(); }
@Override public void close() throws IOException { this.zout.close(); }
protected byte[] zipContent(Map<String, Object> stringObjectMap) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(byteArrayOutputStream); zipOutputStream.setMethod(ZipArchiveOutputStream.STORED); zipOutputStream.setEncoding(ENCODING); for (Map.Entry<String, Object> entry : stringObjectMap.entrySet()) { byte[] data = (byte[]) entry.getValue(); ArchiveEntry archiveEntry = newStoredEntry(entry.getKey(), data); zipOutputStream.putArchiveEntry(archiveEntry); zipOutputStream.write(data); zipOutputStream.closeArchiveEntry(); } zipOutputStream.close(); return byteArrayOutputStream.toByteArray(); }
@Override public void end() { try { zipStream.close(); } catch (IOException error) { throw new ExporterException("Unexpected error closing zip stream!", error); } }
public static void writeArchivedLogTailToStream(File logFile, OutputStream outputStream) throws IOException { if (!logFile.exists()) { throw new FileNotFoundException(); } ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(outputStream); zipOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED); zipOutputStream.setEncoding(ZIP_ENCODING); byte[] content = getTailBytes(logFile); ArchiveEntry archiveEntry = newTailArchive(logFile.getName(), content); zipOutputStream.putArchiveEntry(archiveEntry); zipOutputStream.write(content); zipOutputStream.closeArchiveEntry(); zipOutputStream.close(); }
public void finishSave() throws Docx4JException { try { // Complete the ZIP file // Don't forget to do this or everything will appear // to work, but when you open the zip file you'll get an error // "End-of-central-directory signature not found." zos.close(); } catch (Exception e ) { throw new Docx4JException("Failed to put binary part", e); } }
@Override public void end() { try { zipStream.close(); } catch (IOException error) { throw new ExporterException("Unexpected error closing zip stream!", error); } }
@Override public void close() throws IOException { // Add package.xml descriptor try { writePackage(); } catch (FilterException e) { throw new IOException("Failed to write package", e); } // Close zip stream this.zipStream.close(); } }
@Override public File export() { try { if (repository == null) { initRepository(); } LOGGER.debug("Exporting repository to archive"); File tmp = File.createTempFile("repository", ".zip"); ZipArchiveOutputStream zos = new ZipArchiveOutputStream(tmp); packRepository(localWorkspace, zos); zos.close(); return tmp; } catch (IOException e) { throw new ScmException(e); } }
/** * Packages the source file/folder up as a new Zip file * @param source the source file or folder to be zipped * @param target the zip file to create * @throws IOException */ public static void repackZip(File source, File target) throws IOException{ ZipArchiveOutputStream out = new ZipArchiveOutputStream(target); out.setEncoding("UTF-8"); for(File afile: source.listFiles()){ pack(afile,out, ""); } out.flush(); out.close(); }
public static void zipDir(String zipFile, String dir) throws IOException { File dirObj = new File(dir); ZipArchiveOutputStream out = new ZipArchiveOutputStream(new FileOutputStream(zipFile)); log.info("Creating : {}", zipFile); try { addDir(dirObj, out, ""); } finally { out.close(); } }
public static void zipDir(String zipFile, String dir) throws IOException { File dirObj = new File(dir); ZipArchiveOutputStream out = new ZipArchiveOutputStream(new FileOutputStream(zipFile)); log.info("Creating : {}", zipFile); try { addDir(dirObj, out, ""); } finally { out.close(); } }