Code example for Inflater

Methods: inflate, needsInput, setInput

0
        byte[] b = new byte[1024];
        assertEquals(0, inflater.inflate(b));
        inflater.end();
 
        // Regression for HARMONY-2510 
        inflater = new Inflater();
        inflater.setInput(new byte[] { -1 });
        try { 
            inflater.inflate(b);
 
            // The RI detects malformed data on the malformed input { -1 }. Both 
            // this implementation and the native zlib API return "need input" 
            // on that data. This is an error if the stream is exhausted, but 
            // not one that results in an exception in the Inflater API. 
            assertTrue(inflater.needsInput());
        } catch (DataFormatException e) {
            // expected 
        } 
 
        inflater = new Inflater();
        inflater.setInput(new byte[] { -1, -1, -1 });