Java Utililty Methods Deflate Byte Array

List of utility methods to do Deflate Byte Array

Description

The list of methods to do Deflate Byte Array are organized into topic(s).

Method

voiddeflate(byte[] array)
deflate
InputStream in = new InflaterInputStream(new ByteArrayInputStream(array));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
shovelInToOut(in, bos);
in.close();
System.out.println(bos.toString("UTF-8"));
byte[]deflate(byte[] buf)
deflate
try {
    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;
...
byte[]deflate(byte[] bytes)
deflate
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(bos, new Deflater(Deflater.DEFAULT_COMPRESSION, true));
dos.write(bytes);
dos.close();
return bos.toByteArray();
byte[]deflate(byte[] data)
deflate
Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
deflater.setInput(data);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
deflater.finish();
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
    int count = deflater.deflate(buffer);
    outputStream.write(buffer, 0, count);
...
byte[]deflate(byte[] data)
deflate
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
    Deflater deflater = new Deflater();
    try {
        deflater.setInput(data);
        deflater.finish();
        byte[] buffer = new byte[1024];
        while (!deflater.finished()) {
            int count = deflater.deflate(buffer);
...
byte[]deflate(byte[] data)
deflate compression
Deflater compresser = new Deflater();
compresser.setLevel(Deflater.BEST_COMPRESSION);
compresser.setInput(data);
compresser.finish();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
compresser.deflate(bytes);
while (!compresser.finished()) {
...
byte[]deflate(byte[] data, byte[] dictionary)
DEFLATEs the specified input data.
Deflater deflater = new Deflater(8, true);
if (dictionary != null) {
    deflater.setDictionary(dictionary);
deflater.setInput(data);
deflater.finish();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[256];
...
byte[]deflate(byte[] in)
deflate
ByteArrayOutputStream bos = null;
if (in != null) {
    ByteArrayInputStream bis = new ByteArrayInputStream(in);
    bos = new ByteArrayOutputStream();
    InflaterInputStream gis;
    try {
        gis = new InflaterInputStream(bis);
        byte[] buf = new byte[8192];
...
byte[]deflate(byte[] input)
Method deflate
ByteArrayInputStream bis = new ByteArrayInputStream(input);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(bos);
byte[] buffer = new byte[BUF_LEN];
int bytesRead = bis.read(buffer);
while (bytesRead > 0) {
    dos.write(buffer, 0, bytesRead);
    bytesRead = bis.read(buffer);
...
byte[]deflate(final byte[] pInput)
Compress the given byte array using the deflate algorithm and return the compressed byte array.
final ByteArrayOutputStream vByteArrayStream = new ByteArrayOutputStream(pInput.length);
final OutputStream vDeflaterStream = new DeflaterOutputStream(vByteArrayStream);
vDeflaterStream.write(pInput);
vDeflaterStream.close();
final byte[] vCompressedBytes = vByteArrayStream.toByteArray();
return vCompressedBytes;