Code example for DeflaterInputStream

Methods: availableclosereadskip

0
        assertEquals(22, dis.read(buf, 0, 1024));
        assertEquals(1, dis.available());
        dis.skip(1);
        assertEquals(0, dis.available());
        is = new ByteArrayInputStream(testStr.getBytes("UTF-8"));
        dis = new DeflaterInputStream(is);
        assertEquals(1, dis.available());
        dis.skip(56);
        assertEquals(0, dis.available());
        assertEquals(-1, dis.read(buf, 0, 1024));
        try { 
            dis.skip(-1);
            fail("should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected 
        } 
        assertEquals(0, dis.available());
        // can still skip 
        dis.skip(1);
        dis.close();
        try { 
            dis.skip(1);
            fail("should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
        try { 
            dis.skip(-1);
            fail("should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected 
        } 
 
Contextual code suggestions in your IDE  Get Codota for Java