byte[] buffer = new byte[ 1024 * 1024 ];
byte[] buffer = new byte[ 512 * 1024 ];
	public static void addToJar( File file, File jarFile, File parentDir, boolean compress )	throws FileNotFoundException, IOException	{		File tmpJarFile = File.createTempFile("tmp", ".jar", jarFile.getParentFile() );		JarOutputStream out = new JarOutputStream(				new FileOutputStream( tmpJarFile ) );		if (compress) {			out.setLevel( ZipOutputStream.DEFLATED );		} else {			out.setLevel( ZipOutputStream.STORED );		}		// copy contents of old jar to new jar:		JarFile inputFile = new JarFile( jarFile );		JarInputStream in = new JarInputStream( new FileInputStream( jarFile ) );		CRC32 crc = new CRC32();		byte[] buffer = new byte[ 1024 * 1024 ];		JarEntry entry = (JarEntry) in.getNextEntry();		while (entry != null) {			InputStream entryIn = inputFile.getInputStream(entry); 			add( entry, entryIn, out, crc, buffer );			entryIn.close();			entry = (JarEntry) in.getNextEntry();		}		in.close();		inputFile.close();				int sourceDirLength;		if (parentDir == null) {			sourceDirLength = file.getAbsolutePath().lastIndexOf( File.separatorChar ) + 1;		} else {			sourceDirLength = file.getAbsolutePath().lastIndexOf( File.separatorChar ) + 1				- parentDir.getAbsolutePath().length();					}		addFile( file, out, crc, sourceDirLength, buffer );		out.close();				// remove old jar file and rename temp file to old one:		if (jarFile.delete()) {			if ( !tmpJarFile.renameTo(jarFile) ) {				throw new IOException("Unable to rename temporary JAR file to [" + jarFile.getAbsolutePath() + "]." );			}		} else {			throw new IOException("Unable to delete old JAR file [" + jarFile.getAbsolutePath() + "]." );		}			}