/** * Copies an existing ZIP file and removes entries with given paths. * * @param zip * an existing ZIP file (only read) * @param paths * paths of the entries to remove * @param destOut * new ZIP destination output stream * @since 1.14 */ public static void removeEntries(File zip, String[] paths, OutputStream destOut) { if (log.isDebugEnabled()) { log.debug("Copying '" + zip + "' to an output stream and removing paths " + Arrays.asList(paths) + "."); } ZipOutputStream out = null; try { out = new ZipOutputStream(destOut); copyEntries(zip, out, new HashSet<String>(Arrays.asList(paths))); } finally { IOUtils.closeQuietly(out); } }
/** * Copies an existing ZIP file and removes entries with given paths. * * @param zip * an existing ZIP file (only read) * @param paths * paths of the entries to remove * @param destZip * new ZIP file created. * @since 1.7 */ public static void removeEntries(File zip, String[] paths, File destZip) { if (log.isDebugEnabled()) { log.debug("Copying '" + zip + "' to '" + destZip + "' and removing paths " + Arrays.asList(paths) + "."); } ZipOutputStream out = null; try { out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destZip))); copyEntries(zip, out, new HashSet<String>(Arrays.asList(paths))); } catch (IOException e) { throw ZipExceptionUtil.rethrow(e); } finally { IOUtils.closeQuietly(out); } }
/** * Copies an existing ZIP file and appends it with new entries. * * @param zip * an existing ZIP file (only read). * @param entries * new ZIP entries appended. * @param destOut * new ZIP destination output stream */ public static void addEntries(File zip, ZipEntrySource[] entries, OutputStream destOut) { if (log.isDebugEnabled()) { log.debug("Copying '" + zip + "' to a stream and adding " + Arrays.asList(entries) + "."); } ZipOutputStream out = null; try { out = new ZipOutputStream(destOut); copyEntries(zip, out); for (int i = 0; i < entries.length; i++) { addEntry(entries[i], out); } out.finish(); } catch (IOException e) { ZipExceptionUtil.rethrow(e); } }
/** * Copies an existing ZIP file and appends it with new entries. * * @param is * an existing ZIP input stream. * @param entries * new ZIP entries appended. * @param destOut * new ZIP destination output stream * * @since 1.9 */ public static void addEntries(InputStream is, ZipEntrySource[] entries, OutputStream destOut) { if (log.isDebugEnabled()) { log.debug("Copying input stream to an output stream and adding " + Arrays.asList(entries) + "."); } ZipOutputStream out = null; try { out = new ZipOutputStream(destOut); copyEntries(is, out); for (int i = 0; i < entries.length; i++) { addEntry(entries[i], out); } out.finish(); } catch (IOException e) { ZipExceptionUtil.rethrow(e); } }
/** * Copies an existing ZIP file and removes entries with given paths. * * @param zip * an existing ZIP file (only read) * @param paths * paths of the entries to remove * @param destZip * new ZIP file created. * @since 1.7 */ public static void removeEntries(File zip, String[] paths, File destZip) { if (log.isDebugEnabled()) { log.debug("Copying '" + zip + "' to '" + destZip + "' and removing paths " + Arrays.asList(paths) + "."); } ZipOutputStream out = null; try { out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destZip))); copyEntries(zip, out, new HashSet<String>(Arrays.asList(paths))); } catch (IOException e) { throw ZipExceptionUtil.rethrow(e); } finally { IOUtils.closeQuietly(out); } }
/** * Copies an existing ZIP file and appends it with new entries. * * @param is * an existing ZIP input stream. * @param entries * new ZIP entries appended. * @param destOut * new ZIP destination output stream * * @since 1.9 */ public static void addEntries(InputStream is, ZipEntrySource[] entries, OutputStream destOut) { if (log.isDebugEnabled()) { log.debug("Copying input stream to an output stream and adding " + Arrays.asList(entries) + "."); } ZipOutputStream out = null; try { out = new ZipOutputStream(destOut); copyEntries(is, out); for (int i = 0; i < entries.length; i++) { addEntry(entries[i], out); } out.finish(); } catch (IOException e) { ZipExceptionUtil.rethrow(e); } }
/** * Copies an existing ZIP file and appends it with new entries. * * @param zip * an existing ZIP file (only read). * @param entries * new ZIP entries appended. * @param destOut * new ZIP destination output stream */ public static void addEntries(File zip, ZipEntrySource[] entries, OutputStream destOut) { if (log.isDebugEnabled()) { log.debug("Copying '" + zip + "' to a stream and adding " + Arrays.asList(entries) + "."); } ZipOutputStream out = null; try { out = new ZipOutputStream(destOut); copyEntries(zip, out); for (int i = 0; i < entries.length; i++) { addEntry(entries[i], out); } out.finish(); } catch (IOException e) { ZipExceptionUtil.rethrow(e); } }