List of usage examples for java.util.zip Deflater HUFFMAN_ONLY
int HUFFMAN_ONLY
To view the source code for java.util.zip Deflater HUFFMAN_ONLY.
Click Source Link
From source file:prz.PRZ.java
/** * * @param bytes/*from w w w. j av a 2s . 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; }