Code example for ZipOutputStream

Methods: close, putNextEntry, setMethod, write

0
    public void test_write$BII_2() throws IOException { 
        // Regression for HARMONY-577 
        File f1 = File.createTempFile("testZip1", "tst");
        f1.deleteOnExit();
        FileOutputStream stream1 = new FileOutputStream(f1);
        ZipOutputStream zip1 = new ZipOutputStream(stream1);
        zip1.putNextEntry(new ZipEntry("one"));
        zip1.setMethod(ZipOutputStream.STORED);
        zip1.setMethod(ZipEntry.STORED);
 
        zip1.write(new byte[2]);
 
        try { 
            zip1.putNextEntry(new ZipEntry("Second"));
            fail("ZipException expected");
        } catch (ZipException e) {
            // expected - We have not set an entry 
        } 
 
        try { 
            zip1.write(new byte[2]); // try to write data without entry
            fail("expected IOE there");
        } catch (IOException e2) {
            // expected 
        } 
 
        zip1.close();
    } 
 
    @Override 
    protected void setUp() throws Exception { 
        super.setUp();