Code example for Deflater

Methods: deflatefinishsetInput

0
        if (StringUtils.isEmpty(inputString)) {
            return inputString;
        } 
        // Compress the bytes 
        byte[] output = new byte[2048];
        Deflater compresser = new Deflater();
        try { 
            compresser.setInput(inputString.getBytes("UTF-8"));
            compresser.finish();
            int compressedDataLength = compresser.deflate(output);
            byte[] copy = new byte[compressedDataLength];
            System.arraycopy(output, 0, copy, 0,
                    Math.min(output.length, compressedDataLength));
            return Base64.encodeBase64URLSafeString(copy);
        } catch (UnsupportedEncodingException e) {
            logger.warn("Not able to encode facet URL: " + inputString, e);
        } 
 
        return inputString;
    } 
Connect your IDE to all the code out there  Get Codota for Java