Reputation: 79
i want to overwrite the existing zip file(which mean i add new file in existing zip file) but here show this error (java.util.zip.ZipError: zip END header not found)
private void updateZip(String fileName, String scenarioDirectory){
System.out.println("File Name : " +fileName);
System.out.println("Scenario Directory : " +scenarioDirectory);
String scenarioName ="12345";
Path myFilePath = Paths.get(fileName);
Path zipFilePath = Paths.get(scenarioDirectory);
FileSystem fs;
try {
fs = FileSystems.newFileSystem(zipFilePath,null);
Path fileInsideZipPath = fs.getPath(scenarioName);
Files.copy(myFilePath, fileInsideZipPath);
fs.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Upvotes: 1
Views: 1394
Reputation: 820
Try this :
if your file exist then delete it ant after save the new.
Or Added a file directly in the zip code since this example https://stackoverflow.com/a/17500924/4017037
Upvotes: 1