Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set compression method? #111

Open
LSDsl opened this issue Aug 31, 2018 · 5 comments
Open

How to set compression method? #111

LSDsl opened this issue Aug 31, 2018 · 5 comments

Comments

@LSDsl
Copy link

LSDsl commented Aug 31, 2018

How to set compression Store (no compression)?

@toomasr
Copy link
Contributor

toomasr commented Sep 1, 2018

There are couple of methods that accept the compression level in ZipUtil. See public static void pack(File sourceDir, File targetZip, NameMapper mapper, int compressionLevel) for example. The compression level comes from zip.util.Deflater class. You are looking for Deflater.NO_COMPRESSION.

@LSDsl
Copy link
Author

LSDsl commented Sep 1, 2018

Deflater with NO_COMPRESSION not same as Store. That is in ZipOutputStream.setMethod(STORED) STORED

@toomasr
Copy link
Contributor

toomasr commented Sep 5, 2018

I'm quite confused about the difference of levels in ZipOutputStream and Deflater. There is some information at https://stackoverflow.com/questions/1206970/how-to-create-uncompressed-zip-archive-in-java/

Based on https://en.wikipedia.org/wiki/Zip_(file_format)#Compression_methods it might even be that they use the different name (STORE vs NO_COMPRESSION) for the same thing.

Are you getting any exceptions when you use NO_COMPRESSION and you actually wish to use STORED?

@LSDsl
Copy link
Author

LSDsl commented Sep 6, 2018

I need send zips to another software and it need STORE.
For example test- test file. store.zip- zip with STORE, no_compression.zip- DEFLATE with NO_COMPRESSION
store.zip
no_compression.zip
test.txt

U can see diffrenece in size. Also U can use WinRar to see info. For store.zip - it show 1.0/Store. For no_compression.zip it show 2.0/Deflate. So it has some differences.

@toomasr
Copy link
Contributor

toomasr commented Sep 6, 2018

Understood. Yes, there isn't a way to accomplish this. I'll give this some thought how to get there. As I understand from the JavaDoc it seems that you need to specify STORED to the outputstream AND also to each entry with setMethod(STORED). I haven't tested it though.

I'll think about adding a somesort of a mapper to the pack method where users can tweak the entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants