Code example for ZipFile

Methods: closegetEntrygetInputStream

0
     * java.util.zip.ZipFile#close() 
     */ 
    public void test_close() throws IOException { 
        // Test for method void java.util.zip.ZipFile.close() 
        File fl = new File(tempFileName);
        ZipFile zf = new ZipFile(fl);
        InputStream is1 = zf.getInputStream(zf.getEntry("File1.txt"));
        InputStream is2 = zf.getInputStream(zf.getEntry("File2.txt"));
 
        is1.read();
        is2.read();
 
        zf.close();
 
        try { 
            is1.read();
            fail("IOException expected");
        } catch (IOException ee) {
            // expected 
        } 
Experience pair programming with AI  Get Codota for Java