Code example for Deflater

Methods: deflatefinishsetInput

0
		// Encode a String into bytes 
		byte[] input = baos.toByteArray();
 
		// Compress the bytes 
		byte[] output1 = new byte[input.length];
		Deflater compresser = new Deflater();
		compresser.setInput(input);
		compresser.finish();
		int compressedDataLength = compresser.deflate(output1);
 
		System.out.println("input len="+input.length+" output len="+compressedDataLength);
		byte[] compressed2 = Arrays.copyOfRange(output1, 0, compressedDataLength);
		String result2 = Base64.encodeBase64URLSafeString(compressed2);
		System.out.println("url param length=" + result2.length() + " original len="+all.length());
		System.out.println("url param="+result2);
		byte[] afterBase64 = Base64.decodeBase64(result2);
 
		System.out.println("len bytes=" + afterBase64.length + " before="
				+ compressed2.length + " output1=" + output1.length
				+ " compressLen=" + compressedDataLength);