Code example for Inflater

Methods: end, inflate, setInput

0
                    "Final decompressed data does not equal the original data", 
                    byteArray[i] == outPutInf[i]);
        } 
        assertEquals(
                "final decompressed data contained more bytes than original - inflateB", 
                0, outPutInf[byteArray.length]);
        // testing for an empty input array 
        byte outPutBuf[] = new byte[500];
        byte emptyArray[] = new byte[11];
        int x = 0;
        Deflater defEmpty = new Deflater(3);
        defEmpty.setInput(emptyArray);
        while (!(defEmpty.needsInput())) {
            x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x);
        } 
        defEmpty.finish();
        while (!(defEmpty.finished())) {
            x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x);
        } 
        assertTrue(
                "the total number of byte from deflate did not equal getTotalOut - inflate(byte)", 
                x == defEmpty.getTotalOut());
        assertTrue(
                "the number of input byte from the array did not correspond with getTotalIn - inflate(byte)", 
                defEmpty.getTotalIn() == emptyArray.length);
        Inflater infEmpty = new Inflater();
        try { 
            while (!(infEmpty.finished())) {
                if (infEmpty.needsInput()) {
                    infEmpty.setInput(outPutBuf);
                } 
                infEmpty.inflate(outPutInf);
            } 
        } catch (DataFormatException e) {
            fail("Invalid input to be decompressed");