public void save(File outputArchiveFile) throws IOException {
  JarInputStream zin=null;
  JarOutputStream zout=null;
  try {
    byte[] buf=new byte[1024];
    zin=new JarInputStream(new FileInputStream(jarFile));
    zout=new JarOutputStream(new FileOutputStream(outputArchiveFile));
    JarEntry entry=zin.getNextJarEntry();
    while (entry != null) {
      if (jarEntries.containsKey(entry.getName()) && !jarEntriesToAdd.containsKey(entry.getName())) {
        zout.putNextEntry(jarEntries.get(entry.getName()));
        int len;
        while ((len=zin.read(buf)) > 0) {
          zout.write(buf,0,len);
        }
        zout.closeEntry();
      }
      entry=zin.getNextJarEntry();
    }
    for (    Entry<String,byte[]> jarEntryToAdd : jarEntriesToAdd.entrySet()) {
      String entryName=jarEntryToAdd.getKey();
      byte[] bytes=jarEntryToAdd.getValue();
      InputStream fin=null;
      try {
        fin=new ByteArrayInputStream(bytes);
        zout.putNextEntry(jarEntries.get(entryName));
        int len;
        while ((len=fin.read(buf)) > 0) {
          zout.write(buf,0,len);
        }
        zout.closeEntry();
      }
  finally {
        if (fin != null) {
          fin.close();
        }
      }
    }
  }
  finally {
    if (zin != null) {
      zin.close();
    }
    if (zout != null) {
      zout.close();
    }
  }
}

public void save ( File outputArchiveFile ) throws IOException { JarInputStream zin = null ; JarOutputStream zout = null ; try { byte [ ] buf = new byte [ 1024 ] ; zin = new JarInputStream ( new FileInputStream ( jarFile ) ) ; zout = new JarOutputStream ( new FileOutputStream ( outputArchiveFile ) ) ; JarEntry entry = zin . getNextJarEntry ( ) ; while ( entry != null ) { if ( jarEntries . containsKey ( entry . getName ( ) ) && ! jarEntriesToAdd . containsKey ( entry . getName ( ) ) ) { zout . putNextEntry ( jarEntries . get ( entry . getName ( ) ) ) ; int len ; while ( ( len = zin . read ( buf ) ) > 0 ) { zout . write ( buf , 0 , len ) ; } zout . closeEntry ( ) ; } entry = zin . getNextJarEntry ( ) ; } for ( Entry < String , byte [ ] > jarEntryToAdd : jarEntriesToAdd . entrySet ( ) ) { String entryName = jarEntryToAdd . getKey ( ) ; byte [ ] bytes = jarEntryToAdd . getValue ( ) ; InputStream fin = null ; try { fin = new ByteArrayInputStream ( bytes ) ; zout . putNextEntry ( jarEntries . get ( entryName ) ) ; int len ; while ( ( len = fin . read ( buf ) ) > 0 ) { zout . write ( buf , 0 , len ) ; } zout . closeEntry ( ) ; } finally { if ( fin != null ) { fin . close ( ) ; } } } } finally { if ( zin != null ) { zin . close ( ) ; } if ( zout != null ) { zout . close ( ) ; } } }
writes the modified output archive to a file
