Code example for FilterOutputStream

Methods: flush, write

0
        } 
    } 
 
    public void test_flush() throws IOException { 
        Support_OutputStream sos = new Support_OutputStream(550);
        os = new FilterOutputStream(sos);
        os.write(fileString.getBytes(), 0, 500);
        os.flush();
        assertEquals("Test 1: Bytes not written after flush;",
                500, sos.size());
 
        sos.setThrowsException(true);
        try { 
            os.flush();
            fail("Test 2: IOException expected.");
        } catch (IOException e) {
            // Expected. 
        } 
        sos.setThrowsException(false);
    }