// copy the files from the old JAR to the new, but don't close the new JAR yet
while ((inEnt = in.getNextJarEntry()) != null) {
JarEntry outEnt = new JarEntry(inEnt); // copy size, modification time etc.
byte[] data = new byte[(int)inEnt.getSize()];
in.read(data); // read data for this old entry
in.closeEntry();
out.putNextEntry(outEnt);
out.write(data); // copy it to the new entry
out.closeEntry();
}
// and *now* we close the new JAR file.