Code example for Inflater

Methods: getBytesWrittengetTotalIngetTotalOutinflatesetInput

0
     * @tests java.util.zip.Deflater#getBytesRead() 
     */ 
    public void test_getBytesWritten() throws DataFormatException, UnsupportedEncodingException { 
        // Regression test for HARMONY-158 
        Deflater def = new Deflater();
        Inflater inf = new Inflater();
        assertEquals(0, def.getTotalIn());
        assertEquals(0, def.getTotalOut());
        assertEquals(0, def.getBytesWritten());
        // Encode a String into bytes 
        String inputString = "blahblahblah??";
        byte[] input = inputString.getBytes("UTF-8");
 
        // Compress the bytes 
        byte[] output = new byte[100];
        def.setInput(input);
        def.finish();
        def.deflate(output);
        inf.setInput(output);
        int compressedDataLength =inf.inflate(input);
        assertEquals(16, inf.getTotalIn());
        assertEquals(compressedDataLength, inf.getTotalOut());
        assertEquals(14, inf.getBytesWritten());
    } 
 
    /** 
     * @tests java.util.zip.Deflater#inflate(byte[], int, int) 
     */