public static byte[] compress(String str) throws IOException {
    if (str == null || str.length() == 0) {
      return null;
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    GZIPOutputStream gzip = new GZIPOutputStream(out);
    gzip.write(str.getBytes(StandardCharsets.UTF_8));
    gzip.close();
    byte[] outBytes = out.toByteArray();
    return outBytes;
  }
Compresses a given String. It is encoded using ISO-8859-1, So any decompression of the
compressed string should also use ISO-8859-1

@param str String to be compressed.
@return compressed bytes
geode-core/src/main/java/org/apache/geode/management/internal/beans/BeanUtilFuncs.java