From 1c669cde805068826e196d2138cea5f03ffffe18 Mon Sep 17 00:00:00 2001 From: nedlir Date: Fri, 25 Feb 2022 23:33:47 +0200 Subject: [PATCH] insertFile added to ZipFileManipulator --- ZipFileManipulator.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ZipFileManipulator.java b/ZipFileManipulator.java index 3aae8b0..8c817b3 100644 --- a/ZipFileManipulator.java +++ b/ZipFileManipulator.java @@ -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(); + } + } + } \ No newline at end of file