@Test public void testCompress() throws IOException { byte[] bytes = new byte[]{31, -117, 8, 0, 0, 0, 0, 0, 0, 0, 99, 100, 98, 6, 0, 29, -128, -68, 85, 3, 0, 0, 0}; Assertions.assertArrayEquals(bytes, CompressUtil.compress(new byte[]{1, 2, 3})); }
public static byte[] compress(final byte[] src) throws IOException { byte[] result; ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); GZIPOutputStream gos = new GZIPOutputStream(bos); try { gos.write(src); gos.finish(); result = bos.toByteArray(); } finally { bos.close(); gos.close(); } return result; }
CompressUtil { public static byte[] compress(final byte[] src) throws IOException { byte[] result; ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); GZIPOutputStream gos = new GZIPOutputStream(bos); try { gos.write(src); gos.finish(); result = bos.toByteArray(); } finally { bos.close(); gos.close(); } return result; } }
CompressUtil { public static byte[] compress(final byte[] src) throws IOException { byte[] result; ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); GZIPOutputStream gos = new GZIPOutputStream(bos); try { gos.write(src); gos.finish(); result = bos.toByteArray(); } finally { bos.close(); gos.close(); } return result; }  }
CompressUtil { public static byte[] compress(final byte[] src) throws IOException { byte[] result; ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); GZIPOutputStream gos = new GZIPOutputStream(bos); try { gos.write(src); gos.finish(); result = bos.toByteArray(); } finally { bos.close(); gos.close(); } return result; }  static byte[] compress(final byte[] src); static byte[] uncompress(final byte[] src); static boolean isCompressData(byte[] bytes); }
CompressUtil { public static byte[] compress(final byte[] src) throws IOException { byte[] result; ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); GZIPOutputStream gos = new GZIPOutputStream(bos); try { gos.write(src); gos.finish(); result = bos.toByteArray(); } finally { bos.close(); gos.close(); } return result; }  static byte[] compress(final byte[] src); static byte[] uncompress(final byte[] src); static boolean isCompressData(byte[] bytes);  }