/** * Compress a byte array using GZIP with the given compression level. */ static byte[] gzip(byte[] data, int level) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length); try (GzipLevelOutputStream out = new GzipLevelOutputStream(baos)) { out.setLevel(level); out.write(data); } return baos.toByteArray(); }
/** * Compress a byte array using GZIP with the given compression level. */ static byte[] gzip(byte[] data, int level) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length); try (GzipLevelOutputStream out = new GzipLevelOutputStream(baos)) { out.setLevel(level); out.write(data); } return baos.toByteArray(); }