Java Deflate Byte Array deflate(byte[] buf)

Here you can find the source of deflate(byte[] buf)

Description

deflate

License

Open Source License

Declaration

static byte[] deflate(byte[] buf) 

Method Source Code


//package com.java2s;

import java.util.zip.*;
import java.io.*;

public class Main {
    static byte[] deflate(byte[] buf) {
        try {/* w w w  .j av  a2s. c om*/
            ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
            DeflaterOutputStream dos = new DeflaterOutputStream(baos);
            dos.write(buf, 0, buf.length);
            dos.close();
            return baos.toByteArray();
        } catch (IOException e) {
            return null;
        }
    }
}

Related

  1. deflate(byte[] array)
  2. deflate(byte[] bytes)
  3. deflate(byte[] data)
  4. deflate(byte[] data)
  5. deflate(byte[] data)