什么是好的压缩库Java? [英] What's a good compression library for Java?

查看:110
本文介绍了什么是好的压缩库Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要压缩应用程序的网络流量中的部分性能。我认为这意味着我需要远离一些较新的算法,如bzip2,我认为我听说更慢。

I need to compress portions of our application's network traffic for performance. I presume this means I need to stay away from some of the newer algorithms like bzip2, which I think I have heard is slower.

推荐答案

您可以使用 Deflater / Inflater ,它内置到JDK中。还有GZIPInputStream和GZIPOutputStream,但它真的取决于你的确切用途。

You can use Deflater/Inflater which is built into the JDK. There are also GZIPInputStream and GZIPOutputStream, but it really depends on your exact use.

编辑:

阅读进一步的评论,看起来网络流量是HTTP。根据服务器,它可能支持压缩(特别是使用deflate / gzip)。然后问题出现在客户端。如果客户端是浏览器,它可能已经支持它。如果您的客户端是Web服务客户端或 http客户端,请检查该包的文档

Reading further comments it looks like the network taffic is HTTP. Depending on the server, it probably has support for compression (especially with deflate/gzip). The problem then becomes on the client. If the client is a browser it probably already supports it. If your client is a webservices client or an http client check the documentation for that package to see if it is supported.

看起来像jakarta-commons httpclient可能需要您手动进行压缩。要在客户端启用此功能,您需要执行类似于

It looks like jakarta-commons httpclient may require you to manually do the compression. To enable this on the client side you will need to do something like

.addRequestHeader("Accept-Encoding","gzip,deflate");

这篇关于什么是好的压缩库Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆