I have a folder which contains some files, now I want to append these files to a zip which already exists. If the file I am adding to the zip is already there, then I am replacing the old file with the new one. For zip operations I am using zip4j jar. This is the piece of my code
for(File entry : temp.listFiles())
{
String file = entry.getName();
if(trgZip.getFileHeader(file) != null)
{
trgZip.removeFile(file);
}
ZipParameters param = new ZipParameters();
trgZip.addFile(entry, param);
}
But I am getting this exception net.lingala.zip4j.exception.ZipException: cannot delete old zip file can anyone please suggest what should I do to correct this, or where I am going wrong, or how does this removeFile method works, so that I can try locate the point of error.
Thanks in advance