List of utility methods to do Deflate Byte Array
byte[] | deflate(String inString) Applies a standard deflate algo to the input String Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true); byte[] inBytes = inString.getBytes("UTF-8"); deflater.setInput(inBytes); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(inBytes.length); deflater.finish(); byte[] buffer = new byte[IO_BUFFER_SIZE]; while (!deflater.finished()) { int count = deflater.deflate(buffer); ... |
byte[] | deflate(String text, String encode) Deflates (compresses) the specified text. if (encode == null) { encode = "utf-8"; byte[] input = text.getBytes(encode); Deflater deflater = new Deflater(); deflater.setInput(input); deflater.finish(); ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length); ... |
byte[] | deflateBuffer(byte[] uncompressedBuffer) deflate Buffer final DeflaterOutputStream deflateStream = new DeflaterOutputStream(new ByteArrayOutputStream()); deflateStream.write(uncompressedBuffer, 0, uncompressedBuffer.length); deflateStream.close(); return uncompressedBuffer; |
byte[] | deflateByteArray(final byte[] array) Deflates the file and returns the deflated file. byte[] retval = null; final Deflater deflater = new Deflater(Deflater.DEFLATED, false); deflater.setInput(array); deflater.finish(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { while (!deflater.finished()) { final byte[] data = new byte[ZIP_BUFFER_SIZE]; ... |
byte[] | deflateGzip(byte[] inputBytes) Deflate a gzip byte array. ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(inputBytes))) { byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE]; while (gzipInputStream.available() == 1) { int size = gzipInputStream.read(buffer); if (size == -1) { break; byteArrayOutputStream.write(buffer, 0, size); return byteArrayOutputStream.toByteArray(); |
byte[] | deflateGzip(final byte[] bts) deflate Gzip final int buffLen = 2 * bts.length; final GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(bts)); final ByteArrayOutputStream out = new ByteArrayOutputStream(buffLen); int len = 0; final byte[] buff = new byte[buffLen]; try { while ((len = in.read(buff)) > 0) out.write(buff, 0, len); ... |
byte[] | deflater(final byte[] inputByte) deflater int compressedDataLength = 0; Deflater compresser = new Deflater(); compresser.setInput(inputByte); compresser.finish(); ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length); byte[] result = new byte[1024]; try { while (!compresser.finished()) { ... |