zip4j icon indicating copy to clipboard operation
zip4j copied to clipboard

Folder merging

Open b1ad3runn3r opened this issue 4 years ago • 0 comments
trafficstars

Hello, is there a way of merging to folders, when getting them packed into a zip archive?

For example, I have dir1/resources, with fol1 and fol2 inside it. I also have dir2/resources with fol3 inside. How do I get an archive with resources folder inside it, that contains fol1, fol2 and fol3? I am using ZipFile.addFolder(), but in final archive I get resource/dir1 and resources/dir2 without resources/dir3.

The code section I use is:

ZipFile zip = new ZipFile("pack.zip");
List<File> dirs = Arrays.asList(
        new File("dir1/resources"),
        new File("dir2/resources")
);
for (File file : dirs){
        try{
                zip.addFolder(file);
            }
        catch(ZipException exception){
                System.out.println(exception.getMessage().toString());
            }
}

There is no exception message getting printed.

b1ad3runn3r avatar Aug 11 '21 01:08 b1ad3runn3r