This is a two part question, really.
Preface: I use WinRAR to compress files. It gives you the option of only compressing certain files. I can filter by file extension so that, say, JPEG files are not compressed, while other files are.
-
Can this be done with ZIP files in general, or is it only a WinRAR/RAR format capability?
-
If it is possible do to with the ZIP format, is there a way I can do that using Java’s ZipOutputStream class? Or, perhaps using some other ZIP Java implementation?
To clarify, I would like to tell my ZipOutputStream to only compress files with a particular extension. Is this possible?
Thanks
Yes, you can do it with
ZipOutputStream. Before each file (or when you want to change it) callsetLevelwith a constant fromDeflater, in your caseDeflater.NO_COMPRESSION. The documentation on this should be clearer.You could easily make a subclass of
ZipOutputStreamthat overridesputNextEntryto handle this logic.