DeflaterInputStream close - 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 close method.

This code example shows how to use the following methods:available, close, read
    /** 
     * @tests DeflaterInputStream#close() 
     */ 
    public void testClose() throws IOException { 
        byte[] buf = new byte[1024];
        DeflaterInputStream dis = new DeflaterInputStream(is);
        assertEquals(1, dis.available());
        dis.close();
        try { 
            dis.available();
            fail("should throw IOException");
        } catch (IOException e) {
            // expected 
        } 
        try { 
            dis.read(buf, 0, 1024);
            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
close Method Overview
Closes this input stream and its underlying input stream, discarding any pending uncompressed data.
See Code Examples for other Java 8 DeflaterInputStream Methods: