/** * zip. * * @param bytes source. * @return compressed byte array. * @throws IOException */ public static byte[] zip(byte[] bytes) throws IOException { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); OutputStream os = new DeflaterOutputStream(bos); try { os.write(bytes); } finally { os.close(); bos.close(); } return bos.toByteArray(); }
/** * zip. * * @param bytes source. * @return compressed byte array. * @throws IOException */ public static byte[] zip(byte[] bytes) throws IOException { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); OutputStream os = new DeflaterOutputStream(bos); try { os.write(bytes); } finally { os.close(); bos.close(); } return bos.toByteArray(); }
/** * unzip. * * @param bytes compressed byte array. * @return byte uncompressed array. * @throws IOException */ public static byte[] unzip(byte[] bytes) throws IOException { UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(bytes); UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); InputStream is = new InflaterInputStream(bis); try { IOUtils.write(is, bos); return bos.toByteArray(); } finally { is.close(); bis.close(); bos.close(); } }
/** * unzip. * * @param bytes compressed byte array. * @return byte uncompressed array. * @throws IOException */ public static byte[] unzip(byte[] bytes) throws IOException { UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(bytes); UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); InputStream is = new InflaterInputStream(bis); try { IOUtils.write(is, bos); return bos.toByteArray(); } finally { is.close(); bis.close(); bos.close(); } }
/** * zip. * * @param bytes source. * @return compressed byte array. * @throws IOException */ public static byte[] zip(byte[] bytes) throws IOException { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); OutputStream os = new DeflaterOutputStream(bos); try { os.write(bytes); } finally { os.close(); bos.close(); } return bos.toByteArray(); }
/** * zip. * * @param bytes source. * @return compressed byte array. * @throws IOException */ public static byte[] zip(byte[] bytes) throws IOException { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); OutputStream os = new DeflaterOutputStream(bos); try { os.write(bytes); } finally { os.close(); bos.close(); } return bos.toByteArray(); }
/** * unzip. * * @param bytes compressed byte array. * @return byte uncompressed array. * @throws IOException */ public static byte[] unzip(byte[] bytes) throws IOException { UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(bytes); UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); InputStream is = new InflaterInputStream(bis); try { IOUtils.write(is, bos); return bos.toByteArray(); } finally { is.close(); bis.close(); bos.close(); } }
/** * unzip. * * @param bytes compressed byte array. * @return byte uncompressed array. * @throws IOException */ public static byte[] unzip(byte[] bytes) throws IOException { UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(bytes); UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); InputStream is = new InflaterInputStream(bis); try { IOUtils.write(is, bos); return bos.toByteArray(); } finally { is.close(); bis.close(); bos.close(); } }