Code example for InputStream

Methods: close, mark, read, reset

0
     */ 
    @TestTargetNew( 
            level = TestLevel.PARTIAL_COMPLETE, 
            method = "getInputStream", 
            args = {java.util.zip.ZipEntry.class}
    ) 
    @KnownFailure("ZipEntry.getInputStream().reset() fails with an IOException") 
    public void test_reset() throws IOException { 
        // read an uncompressed entry 
        ZipEntry zentry = zfile.getEntry("File1.txt");
        InputStream is = zfile.getInputStream(zentry);
        byte[] rbuf1 = new byte[6];
        byte[] rbuf2 = new byte[6];
        int r1, r2;
        r1 = is.read(rbuf1);
        assertEquals(rbuf1.length, r1);
        r2 = is.read(rbuf2);
        assertEquals(rbuf2.length, r2);
 
        is.reset();
        r2 = is.read(rbuf2);
        assertEquals(rbuf2.length, r2);
        is.close();