public static byte [ ] compressBytesNonBase64 ( byte [ ] value ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( value . length ) ; try ( GZIPOutputStream gos = new GZIPOutputStream ( baos ) ) { gos . write ( value ) ; } byte [ ] compressed = baos . toByteArray ( ) ; baos . close ( ) ; return compressed ; }
Encodes the given byte array and then GZIP compresses it .