Open mar1ged opened 5 years ago
There is something that was added with https://github.com/zeroturnaround/zt-zip/pull/112 It seems to have problems on Android I presume. The person hasn't replied back there on platform.
If you need an empty file then why not create it with the standard Java file API? The moment you need to add Zip files you create a zip file.
Then again I see that creating an empty ZIP file is an easy as having a list of predefined bytes there. I just might add it to the library. At least based on https://superuser.com/questions/1205503/empty-zip-file-size-shows-22-bytes-size and https://stackoverflow.com/questions/29234912/how-to-create-minimum-size-empty-zip-file-which-has-22b
The master contains the createEmpty implementation that uses the static bytes from https://en.wikipedia.org/wiki/Zip_(file_format)#Limits to create the file. Let me know how this works for you.
Thanks a lot for your suggestions. I tried something like this already:
List<ZipEntrySource> files = new ArrayList<ZipEntrySource>();
... some for Loop that allows me to add each file dynamically
files.add(new FileSource(nameInZip, file);;
ZipEntrySource[] src = new FileSource[files.size()];
ZipEntrySource[] array = files.toArray(src);
ZipUtil.pack(array, new File( "/tmp/file.zip");
It works but I don't like this Approach because it is not very concise due to the List
to array conversion
Is there really no method that allows me to create a new zip file from scratch and fill it with
File
s (orPath
s in the future)