protected byte[] doCompress(byte[] payload) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GZIPOutputStream compressorOutputStream = new GZIPOutputStream(outputStream, true); try { compressorOutputStream.write(payload, 0, payload.length); compressorOutputStream.finish(); return outputStream.toByteArray(); } finally { Objects.nullSafeClose(compressorOutputStream, outputStream); } } }
@Override public byte[] doCompress(byte[] payload) throws IOException { Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION); ByteArrayOutputStream outputStream = null; DeflaterOutputStream deflaterOutputStream = null; try { outputStream = new ByteArrayOutputStream(); deflaterOutputStream = new DeflaterOutputStream(outputStream, deflater, true); deflaterOutputStream.write(payload, 0, payload.length); deflaterOutputStream.flush(); return outputStream.toByteArray(); } finally { Objects.nullSafeClose(outputStream, deflaterOutputStream); } }
@Override protected byte[] doDecompress(byte[] compressed) throws IOException { byte[] buffer = new byte[512]; ByteArrayOutputStream outputStream = null; GZIPInputStream gzipInputStream = null; ByteArrayInputStream inputStream = null; try { inputStream = new ByteArrayInputStream(compressed); gzipInputStream = new GZIPInputStream(inputStream); outputStream = new ByteArrayOutputStream(); int read = gzipInputStream.read(buffer); while (read != -1) { outputStream.write(buffer, 0, read); read = gzipInputStream.read(buffer); } return outputStream.toByteArray(); } finally { Objects.nullSafeClose(inputStream, gzipInputStream, outputStream); } }
@Override public byte[] doDecompress(byte[] compressed) throws IOException { InflaterOutputStream inflaterOutputStream = null; ByteArrayOutputStream decompressedOutputStream = null; try { decompressedOutputStream = new ByteArrayOutputStream(); inflaterOutputStream = new InflaterOutputStream(decompressedOutputStream); inflaterOutputStream.write(compressed); inflaterOutputStream.flush(); return decompressedOutputStream.toByteArray(); } finally { Objects.nullSafeClose(decompressedOutputStream, inflaterOutputStream); } } }
protected byte[] doCompress(byte[] payload) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GZIPOutputStream compressorOutputStream = new GZIPOutputStream(outputStream, true); try { compressorOutputStream.write(payload, 0, payload.length); compressorOutputStream.finish(); return outputStream.toByteArray(); } finally { Objects.nullSafeClose(compressorOutputStream, outputStream); } } }
protected byte[] doCompress(byte[] payload) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GZIPOutputStream compressorOutputStream = new GZIPOutputStream(outputStream, true); try { compressorOutputStream.write(payload, 0, payload.length); compressorOutputStream.finish(); return outputStream.toByteArray(); } finally { Objects.nullSafeClose(compressorOutputStream, outputStream); } } }
@Override public byte[] doCompress(byte[] payload) throws IOException { Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION); ByteArrayOutputStream outputStream = null; DeflaterOutputStream deflaterOutputStream = null; try { outputStream = new ByteArrayOutputStream(); deflaterOutputStream = new DeflaterOutputStream(outputStream, deflater, true); deflaterOutputStream.write(payload, 0, payload.length); deflaterOutputStream.flush(); return outputStream.toByteArray(); } finally { Objects.nullSafeClose(outputStream, deflaterOutputStream); } }
@Override public byte[] doCompress(byte[] payload) throws IOException { Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION); ByteArrayOutputStream outputStream = null; DeflaterOutputStream deflaterOutputStream = null; try { outputStream = new ByteArrayOutputStream(); deflaterOutputStream = new DeflaterOutputStream(outputStream, deflater, true); deflaterOutputStream.write(payload, 0, payload.length); deflaterOutputStream.flush(); return outputStream.toByteArray(); } finally { Objects.nullSafeClose(outputStream, deflaterOutputStream); } }
@Override protected byte[] doDecompress(byte[] compressed) throws IOException { byte[] buffer = new byte[512]; ByteArrayOutputStream outputStream = null; GZIPInputStream gzipInputStream = null; ByteArrayInputStream inputStream = null; try { inputStream = new ByteArrayInputStream(compressed); gzipInputStream = new GZIPInputStream(inputStream); outputStream = new ByteArrayOutputStream(); int read = gzipInputStream.read(buffer); while (read != -1) { outputStream.write(buffer, 0, read); read = gzipInputStream.read(buffer); } return outputStream.toByteArray(); } finally { Objects.nullSafeClose(inputStream, gzipInputStream, outputStream); } }
@Override protected byte[] doDecompress(byte[] compressed) throws IOException { byte[] buffer = new byte[512]; ByteArrayOutputStream outputStream = null; GZIPInputStream gzipInputStream = null; ByteArrayInputStream inputStream = null; try { inputStream = new ByteArrayInputStream(compressed); gzipInputStream = new GZIPInputStream(inputStream); outputStream = new ByteArrayOutputStream(); int read = gzipInputStream.read(buffer); while (read != -1) { outputStream.write(buffer, 0, read); read = gzipInputStream.read(buffer); } return outputStream.toByteArray(); } finally { Objects.nullSafeClose(inputStream, gzipInputStream, outputStream); } }
@Override public byte[] doDecompress(byte[] compressed) throws IOException { InflaterOutputStream inflaterOutputStream = null; ByteArrayOutputStream decompressedOutputStream = null; try { decompressedOutputStream = new ByteArrayOutputStream(); inflaterOutputStream = new InflaterOutputStream(decompressedOutputStream); inflaterOutputStream.write(compressed); inflaterOutputStream.flush(); return decompressedOutputStream.toByteArray(); } finally { Objects.nullSafeClose(decompressedOutputStream, inflaterOutputStream); } } }
@Override public byte[] doDecompress(byte[] compressed) throws IOException { InflaterOutputStream inflaterOutputStream = null; ByteArrayOutputStream decompressedOutputStream = null; try { decompressedOutputStream = new ByteArrayOutputStream(); inflaterOutputStream = new InflaterOutputStream(decompressedOutputStream); inflaterOutputStream.write(compressed); inflaterOutputStream.flush(); return decompressedOutputStream.toByteArray(); } finally { Objects.nullSafeClose(decompressedOutputStream, inflaterOutputStream); } } }