Code example for InflaterInputStream

Methods: available, skip

0
    } 
 
    public void testAvailableSkip() throws Exception { 
        // this byte[] is a deflation of these bytes: { 1, 3, 4, 6 } 
        byte[] deflated = { 72, -119, 99, 100, 102, 97, 3, 0, 0, 31, 0, 15, 0 };
        InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated));
        assertEquals(1, in.available());
        assertEquals(4, in.skip(4));
        assertEquals(0, in.available());
    } 
 
    public void testAvailableEmptySource() throws Exception { 
        // this byte[] is a deflation of the empty file 
        byte[] deflated = { 120, -100, 3, 0, 0, 0, 0, 1 };
        InputStream in = new InflaterInputStream(new ByteArrayInputStream(deflated));
        assertEquals(-1, in.read());
        assertEquals(-1, in.read());
        assertEquals(0, in.available());
    } 
 
	/**