"\", path \"" + path +
"\", new file \"" + newFileName +
"\", old file \"" + oldFileName + "\"");
ZipEntry entry = null;
File file = new File(zipName);
if (file.exists()) {
ZipFile zipFile = new ZipFile(file.getAbsolutePath());
Enumeration zipEntries = zipFile.entries();
// create your output zip file
ZipOutputStream newZip = new ZipOutputStream(
new FileOutputStream(new File(file.getAbsolutePath() + "_TMP")));
// Get all data (except the oldFileName) from zip file and
// write it to the tmp zip file
while (zipEntries.hasMoreElements()) {
entry = (ZipEntry) zipEntries.nextElement();
if (entry.getName().equalsIgnoreCase(oldFileName))
continue;
newZip.putNextEntry(new ZipEntry(entry.getName()));
InputStream is = zipFile.getInputStream(entry);
try {
dump(is,newZip);
} finally {
newZip.closeEntry();
is.close();
}
}
zipFile.close();
// Write the new fileName to the zip
entry = new ZipEntry(path);
newZip.putNextEntry(entry);
try {
FileInputStream fis = new FileInputStream(newFileName);
dump(fis,newZip);
fis.close();