Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import java.util.zip.GZIPOutputStream;

public class Main {

    public static final byte[] compress(byte[] val) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(val.length);
        GZIPOutputStream gos = new GZIPOutputStream(bos);
        gos.write(val, 0, val.length);
        gos.finish();
        gos.close();

        // store it and set compression flag
        return bos.toByteArray();
    }
}