Steve Cohen
Steve Cohen

Reputation: 4859

Compression Compatability between Java and C

I've a situation where my java desktop client software, which uses JSON to communicate with a legacy backend system written in C (there is a a converter on the server) is simply eating too much bandwidth, when deployed in volume in the field.

After studying compression options I've come to the conclusion that the popular JSON compression tools don't fit my situation. They seem to be based on the scenario of passing database query results across the network, which is not my situation. There is no handy row/column algorithm available lending itself to easy compression. Our data is more complicated.

So we get down to using compression, Java's DeflaterOutputStream and InflaterInputStream (or perhaps their GZIP and or ZIP flavors). On the C side, there would be something similar, possibly the zlib library which is available through RedHat, which our servers run on.

Before I step into a can of worms, can someone with experience tell me how compatible zlib compression and the compression supported by Java are? Is one flavor or the other of the Java compression options better than another? Faster than another?

By the way, the protocol is two-way. Server and Client both use JSON to encode messages, so both sides need to be able to compress and decompress in my scenario. Thanks in advance.

Upvotes: 0

Views: 663

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533780

Deflator, GZIP and ZIP library in Java all use the zlib library to do the actual compression so they should be exactly the same, not just compatible. Most likely GZIP and ZIP is more portable as Deflator is just the compressed data with a smaller header/footer

Upvotes: 1

Related Questions