List of usage examples for java.util.zip Deflater setStrategy
public void setStrategy(int strategy)
From source file:prz.PRZ.java
/** * * @param bytes//from w ww . ja va2s . c o m * @return */ public static byte[] huffman_test(byte[] bytes) { Deflater d = new Deflater(9, true); d.setStrategy(Deflater.HUFFMAN_ONLY); DeflaterOutputStream dfos; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { dfos = new DeflaterOutputStream(baos, d); dfos.write(bytes); dfos.finish(); byte[] y = baos.toByteArray(); System.out.println("HUFF-> BitLength:" + (bytes.length * 8) + "| BestLength: " + (y.length * 8) + "| Ratio: " + ((double) y.length / (bytes.length))); return y; } catch (IOException ex) { Logger.getLogger(PRZ.class.getName()).log(Level.SEVERE, null, ex); } return null; }