@Test public void testUncompress() 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(new byte[]{1, 2, 3}, CompressUtil.uncompress(bytes)); }
public static byte[] uncompress(final byte[] src) throws IOException { byte[] result; byte[] uncompressData = new byte[src.length]; ByteArrayInputStream bis = new ByteArrayInputStream(src); GZIPInputStream iis = new GZIPInputStream(bis); ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); try { while (true) { int len = iis.read(uncompressData, 0, uncompressData.length); if (len <= 0) { break; } bos.write(uncompressData, 0, len); } bos.flush(); result = bos.toByteArray(); } finally { bis.close(); iis.close(); bos.close(); } return result; }
CompressUtil { public static byte[] uncompress(final byte[] src) throws IOException { byte[] result; byte[] uncompressData = new byte[src.length]; ByteArrayInputStream bis = new ByteArrayInputStream(src); GZIPInputStream iis = new GZIPInputStream(bis); ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); try { while (true) { int len = iis.read(uncompressData, 0, uncompressData.length); if (len <= 0) { break; } bos.write(uncompressData, 0, len); } bos.flush(); result = bos.toByteArray(); } finally { bis.close(); iis.close(); bos.close(); } return result; } }
CompressUtil { public static byte[] uncompress(final byte[] src) throws IOException { byte[] result; byte[] uncompressData = new byte[src.length]; ByteArrayInputStream bis = new ByteArrayInputStream(src); GZIPInputStream iis = new GZIPInputStream(bis); ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); try { while (true) { int len = iis.read(uncompressData, 0, uncompressData.length); if (len <= 0) { break; } bos.write(uncompressData, 0, len); } bos.flush(); result = bos.toByteArray(); } finally { bis.close(); iis.close(); bos.close(); } return result; }  }
CompressUtil { public static byte[] uncompress(final byte[] src) throws IOException { byte[] result; byte[] uncompressData = new byte[src.length]; ByteArrayInputStream bis = new ByteArrayInputStream(src); GZIPInputStream iis = new GZIPInputStream(bis); ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); try { while (true) { int len = iis.read(uncompressData, 0, uncompressData.length); if (len <= 0) { break; } bos.write(uncompressData, 0, len); } bos.flush(); result = bos.toByteArray(); } finally { bis.close(); iis.close(); bos.close(); } return result; }  static byte[] compress(final byte[] src); static byte[] uncompress(final byte[] src); static boolean isCompressData(byte[] bytes); }
CompressUtil { public static byte[] uncompress(final byte[] src) throws IOException { byte[] result; byte[] uncompressData = new byte[src.length]; ByteArrayInputStream bis = new ByteArrayInputStream(src); GZIPInputStream iis = new GZIPInputStream(bis); ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length); try { while (true) { int len = iis.read(uncompressData, 0, uncompressData.length); if (len <= 0) { break; } bos.write(uncompressData, 0, len); } bos.flush(); result = bos.toByteArray(); } finally { bis.close(); iis.close(); bos.close(); } return result; }  static byte[] compress(final byte[] src); static byte[] uncompress(final byte[] src); static boolean isCompressData(byte[] bytes);  }