Java 8 DeflaterInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DeflaterInputStream class.

This code example shows how to use the following methods: close, mark
    /** 
     * @tests DeflaterInputStream#mark() 
     */ 
    public void testMark() throws IOException { 
        // mark do nothing 
        DeflaterInputStream dis = new DeflaterInputStream(is);
        dis.mark(-1);
        dis.mark(0);
        dis.mark(1);
        dis.close();
        dis.mark(1);
    } 
 
    /** 
     * @tests DeflaterInputStream#markSupported() 
     */ 
    public void testMarkSupported() throws IOException { 
        DeflaterInputStream dis = new DeflaterInputStream(is);
        assertFalse(dis.markSupported());
        dis.close();
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, read
    } 
 
    public void testReadExceptions() throws IOException {
        byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        byte[] buffer = new byte[8];
        InputStream in = new DeflaterInputStream(new ByteArrayInputStream(data));
        try { 
            in.read(buffer, 0, 10);
            fail();
        } catch (IndexOutOfBoundsException expected) {
        } 
        try { 
            in.read(null, 0, 5);
            fail();
        } catch (NullPointerException expected) {
        } 
        try { 
            in.read(buffer, -1, 5);
            fail();
        } catch (IndexOutOfBoundsException expected) {

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
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 
        } 
    } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: close, read
    } 
 
    public void testReadExceptions() throws IOException { 
        byte[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        byte[] buffer = new byte[8];
        InputStream in = new DeflaterInputStream(new ByteArrayInputStream(data));
        try { 
            in.read(buffer, 0, 10);
            fail();
        } catch (IndexOutOfBoundsException expected) {
        } 
        try { 
            in.read(null, 0, 5);
            fail();
        } catch (NullPointerException expected) {
        } 
        try { 
            in.read(buffer, -1, 5);
            fail();
        } catch (IndexOutOfBoundsException expected) {

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    } 
    if (name.endsWith(".zip")) {
      return new ZipInputStream(in);
    } 
    if (name.endsWith(".deflate")) {
      return new DeflaterInputStream(in);
    } 
    return in;
  } 
 
  /** 
   * @param in   stream to read and copy 
   * @param file file to write stream's contents to 
   * @throws IOException if the stream can't be read or the file can't be written 
   */ 
  public static void copyStreamToFile(InputStream in, File file) throws IOException {
    FileOutputStream out = new FileOutputStream(file);
    try { 
      ByteStreams.copy(in, out);
    } finally { 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 DeflaterInputStream Methods: