Code example for Deflater

Methods: setLevel

0
 
public class ZlibArchiver implements Archiver { 
 
	public byte[] compress(byte[] input) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		Deflater comp = new Deflater();
		comp.setLevel(Deflater.BEST_COMPRESSION);
		 
		DeflaterOutputStream dos = new DeflaterOutputStream(out, comp);
		 
		dos.write(input);
		dos.finish();
		return out.toByteArray();
	} 
 
	public byte[] decompress(byte[] input) throws IOException {
		Inflater decomp = new Inflater();
		decomp.setInput(input);
		ByteArrayOutputStream decomped = new ByteArrayOutputStream();
		 
Contextual code suggestions in your IDE  Get Codota for Java