@Test public void testCompress () { byte[] data = new byte[4096]; Random random = new Random(); random.nextBytes(data); byte[] compressedData = GZipUtils.compress(data); assertNotNull(compressedData); assertEquals(true, compressedData.length > 0); }
public static byte[] compress (byte[] uncompressedData) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (GZIPOutputStream os = new GZIPOutputStream(baos)) { os.write(uncompressedData); } catch (IOException e) { Log.e(LOG_TAG, "unable to compress resource: ", e); throw new IllegalStateException("unable to compress resource: ", e); } return baos.toByteArray(); }
GZipUtils { public static byte[] compress (byte[] uncompressedData) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (GZIPOutputStream os = new GZIPOutputStream(baos)) { os.write(uncompressedData); } catch (IOException e) { Log.e(LOG_TAG, "unable to compress resource: ", e); throw new IllegalStateException("unable to compress resource: ", e); } return baos.toByteArray(); } }
GZipUtils { public static byte[] compress (byte[] uncompressedData) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (GZIPOutputStream os = new GZIPOutputStream(baos)) { os.write(uncompressedData); } catch (IOException e) { Log.e(LOG_TAG, "unable to compress resource: ", e); throw new IllegalStateException("unable to compress resource: ", e); } return baos.toByteArray(); } protected  GZipUtils(); }
GZipUtils { public static byte[] compress (byte[] uncompressedData) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (GZIPOutputStream os = new GZIPOutputStream(baos)) { os.write(uncompressedData); } catch (IOException e) { Log.e(LOG_TAG, "unable to compress resource: ", e); throw new IllegalStateException("unable to compress resource: ", e); } return baos.toByteArray(); } protected  GZipUtils(); static byte[] compress(byte[] uncompressedData); static byte[] decompress(byte[] compressedData); }
GZipUtils { public static byte[] compress (byte[] uncompressedData) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (GZIPOutputStream os = new GZIPOutputStream(baos)) { os.write(uncompressedData); } catch (IOException e) { Log.e(LOG_TAG, "unable to compress resource: ", e); throw new IllegalStateException("unable to compress resource: ", e); } return baos.toByteArray(); } protected  GZipUtils(); static byte[] compress(byte[] uncompressedData); static byte[] decompress(byte[] compressedData);  }