Code example for GZIPOutputStream

Methods: writeclose

0
 
    @Override 
    protected byte[] doCompress(byte[] plain) throws IOException {
 
        @Cleanup ByteArrayOutputStream bos = new ByteArrayOutputStream();
        @Cleanup GZIPOutputStream gzip = new GZIPOutputStream(bos);
 
        gzip.write(plain);
        gzip.close();
 
        return bos.toByteArray();
 
    } 
 
    @Override 
    protected byte[] doDecompress(byte[] compressed) throws IOException {
 
        @Cleanup 
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        @Cleanup 
Stop searching for code, let great code find you!  Add Codota to your java IDE