简体   繁体   中英

How to add a zipped folder inside an existing zip folder

With the use of createZipReport, I am adding list of files and folders to be zipped up. The createZipReport then calls the zipFileList to zip up the whole folder.

The question is I need to zip a folder inside this already existing folder without changing much.

For example

Directory.zip

  Files
  SubFolder1
  SubFolder2

The files, subFolder1 and subFolder2 are added with the help of fileList in createZipReport

Now I need the subFolder1 to be a zip folder ieSubFolder1.zip

Any suggestions?

You can create new or use existed zip file to add new files and folers with zip4jvm

Path zip = Paths.get("filename.zip");
Collection<Path> paths = Arrays.asList(
        Paths.get("/bikes/ducati-panigale-1199.jpg"),
        Paths.get("/bikes/honda-cbr600rr.jpg"),
        Paths.get("/cars"),
        Paths.get("/saint-petersburg.jpg"));
ZipIt.zip(zip).add(paths);

When you do it multiple times, your existed zip file will not be corrupted and all entires will be there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM