我想覆盖现有的zip文件(这意味着我在现有的zip文件中添加了新文件)但是这里显示了这个错误(java.util.zip.ZipError:找不到zip END标题)
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();
}
}
答案 0 :(得分:1)