XdmZipUtils { public static void writeZipfile(String zipPath, byte[] bytes) throws IOException { FileOutputStream zipos = new FileOutputStream(zipPath); ZipOutputStream zout = new ZipOutputStream(zipos); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ZipInputStream zipis = new ZipInputStream(bis); ZipEntry current_zip_entry = null; boolean found = false; current_zip_entry = zipis.getNextEntry(); while ((current_zip_entry != null) && !found) { zout.putNextEntry(current_zip_entry); byte[] buf = new byte[4096]; int bytesRead = 0; while ((bytesRead = zipis.read(buf)) != -1) { zout.write(buf, 0, bytesRead); } current_zip_entry = zipis.getNextEntry(); } bis.close(); zout.close(); }  static byte[] createXDMPackage(String metadata, String xsl, String c32,
			String index, String readMe, byte[] kekMaskingKey,
			byte[] kekEncryptionKey); static byte[] getUtfCustomBytes(String str); static void addZipEntry(String pathName, byte[] contents, ZipOutputStream zos); static byte[] getEntryBytes(byte[] zipFileBytes,
			String entryName, int entrySize); static ByteArrayOutputStream getByteArrayOutputStream(
			ZipInputStream zipInputstream); static void writeZipfile(String zipPath, byte[] bytes); static final String PATH_INDEX; static final String PATH_README; static final String PATH_METADATA; static final String PATH_C32; static final String PATH_KEKENCRYPT; static final String PATH_KEKMASKING; static final String PATH_XSL; }
@Test public void testCreateXDMPackage_writeZipFile() throws IOException { final String ZIP_PATH = "target/out.zip"; XdmZipUtils.writeZipfile(ZIP_PATH, zip); }