@@ -0,0 +1,2161 @@
+package com.shvid.memcast.compress;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.util.zip.DataFormatException;%0Aimport java.util.zip.Deflater;%0Aimport java.util.zip.Inflater;%0A%0Apublic class CompressionHelper %7B%0A%0A%09public final static int DEFAULT = Deflater.DEFAULT_COMPRESSION;%0A%09public final static int BEST = Deflater.BEST_COMPRESSION;%0A%09public final static int MIDDLE = Deflater.DEFLATED;%0A%09public final static int LOW = Deflater.BEST_SPEED;%0A%09public final static int NO = Deflater.NO_COMPRESSION;%0A%09%0A%09public final static int BUFFER_SIZE = 4092;%0A%09%0A    public static byte%5B%5D compress(byte%5B%5D data, int level) throws IOException %7B%0A    %09if (data == null %7C%7C data.length == 0) %7B%0A    %09%09return data;%0A    %09%7D%0A        ByteArrayOutputStream bout = new ByteArrayOutputStream(data.length);%0A        Deflater deflater = new Deflater();%0A        deflater.setLevel(level);%0A        deflater.setInput(data);%0A        deflater.finish();%0A        byte%5B%5D buf = new byte%5BBUFFER_SIZE%5D;%0A        while (!deflater.finished()) %7B%0A            int count = deflater.deflate(buf);%0A            bout.write(buf, 0, count);%0A        %7D%0A        deflater.end();%0A        bout.close();%0A        return bout.toByteArray();%0A    %7D    %0A    %0A    public final static byte%5B%5D decompress(byte%5B%5D input) throws IOException %7B%0A        if (input == null %7C%7C input.length==0) %7B%0A        %09return input;%0A        %7D%0A        Inflater inflator = new Inflater();%0A        inflator.setInput(input);%0A        ByteArrayOutputStream bin = new ByteArrayOutputStream(input.length);%0A        byte%5B%5D buf = new byte%5BBUFFER_SIZE%5D;%0A        try %7B%0A            while (true) %7B%0A                int count = inflator.inflate(buf);%0A                if (count %3E 0) %7B%0A                    bin.write(buf, 0, count);%0A                %7D else if (count == 0 && inflator.finished()) %7B%0A                    break;%0A                %7D else %7B%0A                    throw new IOException(%22bad zip data, size:%22 + input.length);%0A                %7D%0A            %7D%0A        %7D catch (DataFormatException t) %7B%0A            throw new IOException(t);%0A        %7D finally %7B%0A            inflator.end();%0A        %7D%0A        return bin.toByteArray();%0A    %7D%0A    %0A    %0A%7D

compress helper