DeflaterInputStream read - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DeflaterInputStream read method.

This code example shows how to use the following methods:available, close, read
    /** 
     * @tests DeflaterInputStream#available() 
     */ 
    public void testAvailable() throws IOException { 
        byte[] buf = new byte[1024];
        DeflaterInputStream dis = new DeflaterInputStream(is);
        assertEquals(1, dis.available());
        assertEquals(120, dis.read());
        assertEquals(1, dis.available());
        assertEquals(22, dis.read(buf, 0, 1024));
        assertEquals(1, dis.available());
        assertEquals(-1, dis.read());
        assertEquals(0, dis.available());
        dis.close();
        try { 
            dis.available();
            fail("should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:available, close, read
    /** 
     * @tests DeflaterInputStream#available() 
     */ 
    public void testAvailable() throws IOException { 
        byte[] buf = new byte[1024];
        DeflaterInputStream dis = new DeflaterInputStream(is);
        assertEquals(1, dis.available());
        assertEquals(120, dis.read());
        assertEquals(1, dis.available());
        assertEquals(22, dis.read(buf, 0, 1024));
        assertEquals(1, dis.available());
        assertEquals(-1, dis.read());
        assertEquals(0, dis.available());
        dis.close();
        try { 
            dis.available();
            fail("should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
    } 
5
CodeRank
read Method Overview
Reads a single byte of compressed data from the input stream.
See Code Examples for other Java 8 DeflaterInputStream Methods: