Code example for ZipFile

Methods: close, getEntry, getInputStream

0
        assertNotNull("Could not obtain ZipEntry", zentry);
        int r;
        InputStream in;
 
        zentry = zfile.getEntry("testdir1");
        assertNotNull("Must be able to obtain ZipEntry: testdir1", zentry);
        in = zfile.getInputStream(zentry);
        /* 
         * Android delivers empty InputStream, RI no InputStream at all. The 
         * spec doesn't clarify this, so we need to deal with both situations. 
         */ 
        int data = -1;
        if (in != null) {
            data = in.read();
            in.close();
        } 
        assertEquals("Must not be able to read directory data", -1, data);
    } 
 
    @TestTargetNew( 
        level = TestLevel.PARTIAL_COMPLETE, 
        notes = "IllegalStateException checking.", 
        method = "getEntry", 
        args = {java.lang.String.class}
    ) 
    @KnownFailure("Android does not throw IllegalStateException when using " 
            + "getEntry() after close().") 
    public void test_getEntryLjava_lang_String_Ex() throws IOException { 
        java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
        assertNotNull("Could not obtain ZipEntry", zentry);
        int r;