FileOutputStream out = new FileOutputStream( file); InputStream in = input.getInputStream(entry); int read; while ( (read = in.read( buffer )) != -1) { out.write( buffer, 0, read ); } in.close(); out.close();
	public static void unjar(File jarFile, File targetDir) 	throws FileNotFoundException, IOException 	{		// clear target directory:		if (targetDir.exists()) {			targetDir.delete();		}		// create new target directory:		targetDir.mkdirs(); 		// read jar-file:		String targetPath = targetDir.getAbsolutePath() + File.separatorChar;		byte[] buffer = new byte[ 1024 * 1024 ];		JarFile input = new JarFile( jarFile, false, JarFile.OPEN_READ );		Enumeration enum = input.entries();		for (; enum.hasMoreElements();) {			JarEntry entry = (JarEntry) enum.nextElement();			String path = targetPath + entry.getName();			File file = new File( path );			if (!file.getParentFile().exists()) {				file.getParentFile().mkdirs();			}			FileOutputStream out = new FileOutputStream( file);			InputStream in = input.getInputStream(entry);			int read;			while ( (read = in.read( buffer )) != -1) {				out.write( buffer, 0, read );			}			in.close();			out.close();		}