code: public static boolean addFilesToExistingJar(File jarFile,
  	                                            String basePathWithinJar,
  	                                            Map<String, File> files,
  	                                            ActionOnConflict action) throws IOException
  	{
  
  		// get a temp file
  		File tempFile = FileHelper.createTempFile(jarFile.getName(), null);
  
  		boolean renamed = jarFile.renameTo(tempFile);
  		if (!renamed)
  		{
  			throw new RuntimeException("[ArchiveHelper] {addFilesToExistingJar} " + "Could not rename the file " +
  			                           jarFile.getAbsolutePath() + " to " + tempFile.getAbsolutePath());
  		}
  
  		ZipInputStream jarInput = new ZipInputStream(new FileInputStream(tempFile));
  		ZipOutputStream jarOutput = new ZipOutputStream(new FileOutputStream(jarFile));
  
  		try
  		{
  			switch (action)
  			{
  				case OVERWRITE:
  					overwriteFiles(jarInput, jarOutput, basePathWithinJar, files);
  					break;
  				case CONFLICT:
  					conflictFiles(jarInput, jarOutput, basePathWithinJar, files);
  					break;
  				default:
  					// This should never happen with validation of action taking place in WarDriver class
  					throw new IOException("An invalid ActionOnConflict action was received");
  			}
  		}
  		finally
  		{
  			if (!tempFile.delete())
  				log.warn("Could not delete temp file " + tempFile);
  		}
  		return true;
  	}
docs: Adds a file or files to a jar file, replacing the original one
  
  @param jarFile
  File the jar file
  @param basePathWithinJar
  String the base path to put the files within the Jar
  @param files
  File[] The files. The files will be placed in basePathWithinJar
  
  @throws Exception
  @since 2007-06-07 uses createTempFile instead of Java's createTempFile, increased buffer from 1k to 4k