相关疑难解决方法(0)

为什么gzip压缩缓冲区大小比未压缩缓冲区大?

我正在尝试编写一个compress utils类.
但是在测试期间,我发现结果大于原始缓冲区.
我的代码是对的吗?

请参阅代码:

/**
 * This class provide compress ability
 * <p>
 * Support:
 * <li>GZIP
 * <li>Deflate
 */
public class CompressUtils {
    final public static int DEFAULT_BUFFER_SIZE = 4096; // Compress/Decompress buffer is 4K

    /**
     * GZIP Compress
     * 
     * @param data The data will be compressed
     * @return The compressed data
     * @throws IOException
     */
    public static byte[] gzipCompress(byte[] data) throws IOException {
        Validate.isTrue(ArrayUtils.isNotEmpty(data));

        ByteArrayInputStream bis = new ByteArrayInputStream(data);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        try { …
Run Code Online (Sandbox Code Playgroud)

java gzip

0
推荐指数
1
解决办法
2528
查看次数

标签 统计

gzip ×1

java ×1