insertFile added to ZipFileManipulator

This commit is contained in:
nedlir 2022-02-25 23:33:47 +02:00
parent 4747d5924f
commit 1c669cde80
1 changed files with 14 additions and 0 deletions

View File

@ -36,4 +36,18 @@ public class ZipFileManipulator {
Files.copy(source, outputLocation.toPath());
}
public void insertFile(String targetFile) throws Exception {
Path myFilePath = Paths.get(targetFile);
Path zipFilePath = Paths.get(this.fileName);
try( FileSystem fs = FileSystems.newFileSystem(zipFilePath, null) ){
Path fileInsideZipPath = fs.getPath("/ppt/" + targetFile);
Files.delete(fileInsideZipPath);
Files.copy(myFilePath, fileInsideZipPath);
} catch (IOException e) {
e.printStackTrace();
}
}
}