public static byte[] tryCompress(String str, String encoding) {
        if (str == null || str.length() == 0) {
            return new byte[0];
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try (GZIPOutputStream gzip = new GZIPOutputStream(out)) {
            gzip.write(str.getBytes(encoding));
        } catch (Exception e) {
            log.error("gzip write is fail: {}", e.getMessage());
        }
        return out.toByteArray();
    }
@Test
    public void testTryCompress() throws IOException {
        String inputString = "This is a test string.";
        String encoding = "UTF-8";
        byte[] compressedBytes = IoUtil.tryCompress(inputString, encoding);
        Assert.assertNotNull(compressedBytes);
        Assert.assertTrue(compressedBytes.length > 0);
        try (
                GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedBytes))) {
            byte[] decompressedBytes = new byte[1024];
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            int readBytes;
            while ((readBytes = gzipInputStream.read(decompressedBytes)) > 0) {
                outputStream.write(decompressedBytes, 0, readBytes);
            }
            String decompressedString = outputStream.toString(encoding);
            Assert.assertEquals(inputString, decompressedString);
        }
    }