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 
Experience pair programming with AI  Get Codota for Java