[ACCEPTED]-What's a good compression library for Java?-compression
You can use Deflater/Inflater which is built into the JDK. There 15 are also GZIPInputStream and GZIPOutputStream, but 14 it really depends on your exact use.
Edit:
Reading 13 further comments it looks like the network 12 taffic is HTTP. Depending on the server, it 11 probably has support for compression (especially 10 with deflate/gzip). The problem then becomes 9 on the client. If the client is a browser 8 it probably already supports it. If your 7 client is a webservices client or an http client check 6 the documentation for that package to see 5 if it is supported.
It looks like jakarta-commons 4 httpclient may require you to manually do 3 the compression. To enable this on the 2 client side you will need to do something 1 like
.addRequestHeader("Accept-Encoding","gzip,deflate");
If the network traffic is going over HTTP, most 3 of the various web servers/servlet containers 2 support for negotiated zipping, e.g., mod_deflate 1 for Apache.
Your compression algorithm depends on what 15 your trying to optimize, and how much bandwidth 14 you have available.
If you're on a gigibit 13 LAN, almost any compression algorithm is 12 going to slow your program down just a bit. If 11 your connecting over a WAN or internet, you 10 can afford to do a bit more compression. If 9 you connected to a dialup, you should compress 8 as much as it absolutely possible.
If this 7 is a WAN, you may find hardware solutions 6 like Riverbed's are more effective, as they work across 5 a range of traffic, and don't require any 4 changes to software.
I have a test case 3 which shows the relative compression difference 2 between Deflate, Filtered, BZip2, and lzma. Simply plug in a sample of your 1 data, and test the timing between two machines.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.