private static void writeSplitToZip(final ZipFile sourceZip,
                                        final List<ZipEntryGroup> zipEntryGroupsIn,
                                        final FeedKey feedKey,
                                        final AttributeMap attributeMap,
                                        final FileGroup destFileGroup,
                                        final byte[] buffer) throws IOException {
        LOGGER.debug("writeZip() - START feedKey: {}, destFileGroup: {}", feedKey, destFileGroup);
        final DurationTimer timer = LogUtil.startTimerIfDebugEnabled(LOGGER);
        try {
            // Write zip.
            final AtomicInteger count = new AtomicInteger(0);
            final Path entriesFile = destFileGroup.getEntries();
            try (final Writer entryWriter = Files.newBufferedWriter(entriesFile)) {
                try (final ProxyZipWriter destZipWriter = new ProxyZipWriter(destFileGroup.getZip(), buffer)) {
                    for (final ZipEntryGroup zipEntryGroupIn : zipEntryGroupsIn) {
                        final ZipEntryGroup zipEntryGroupOut = new ZipEntryGroup(feedKey);
                        final String baseNameOut = NumericFileNameUtil.create(count.incrementAndGet());
                        LOGGER.trace("feedKey: {}, baseNameOut: {}, zipEntryGroupIn: {} => zipEntryGroupOut: {}",
                                feedKey, baseNameOut, zipEntryGroupIn, zipEntryGroupOut);
                        zipEntryGroupOut.setManifestEntry(
                                addUnchangedEntry(sourceZip,
                                        destZipWriter,
                                        zipEntryGroupIn.getManifestEntry(),
                                        baseNameOut,
                                        StroomZipFileType.MANIFEST));
                        zipEntryGroupOut.setMetaEntry(
                                addMetaEntry(sourceZip,
                                        destZipWriter,
                                        zipEntryGroupIn.getMetaEntry(),
                                        baseNameOut,
                                        StroomZipFileType.META,
                                        attributeMap));
                        zipEntryGroupOut.setContextEntry(
                                addUnchangedEntry(sourceZip,
                                        destZipWriter,
                                        zipEntryGroupIn.getContextEntry(),
                                        baseNameOut,
                                        StroomZipFileType.CONTEXT));
                        zipEntryGroupOut.setDataEntry(
                                addUnchangedEntry(sourceZip,
                                        destZipWriter,
                                        zipEntryGroupIn.getDataEntry(),
                                        baseNameOut,
                                        StroomZipFileType.DATA));

                        // Write zip entry.
                        LOGGER.trace("Writing entries file {}", entriesFile);
                        zipEntryGroupOut.write(entryWriter);
                    }
                }
            }

            // Write meta.
            AttributeMapUtil.addFeedAndType(attributeMap, feedKey.feed(), feedKey.type());
            AttributeMapUtil.write(attributeMap, destFileGroup.getMeta());
            LOGGER.debug("writeZip() - FINISH feedKey: {}, destFileGroup: {}, count: {}, duration: {}",
                    feedKey, destFileGroup, count, timer);

        } catch (final IOException e) {
            LOGGER.error(e::getMessage, e);
            throw e;
        }
    }
Pkg private to ease testing. splitDirConsumer also there to aid testing.
stroom-proxy/stroom-proxy-app/src/main/java/stroom/proxy/app/handler/ZipSplitter.java