code: public static String compress(String uncompressedValue) throws IOException {
          if (uncompressedValue == null)
              return null;
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          GZIPOutputStream gzip = null;
          try {
              gzip = new GZIPOutputStream(out);
              gzip.write(uncompressedValue.getBytes());
              gzip.close();
              return out.toString("ISO-8859-1");
          }
          finally {
              if (gzip != null)
                  gzip.close();
          }
      }
docs: Compress a string value using GZIP.