Code example for FilterWriter

Methods: write

0
 
        fw = new MyFilterWriter(new OutputStreamWriter(
            new ByteArrayOutputStream()));
 
        try { 
            fw.write(buffer, 0, -1);
            fail("Test 1: IndexOutOfBoundsException expected.");
        } catch (IndexOutOfBoundsException e) {
            // Expected. 
        } 
 
        try { 
            fw.write(buffer, -1, 1);
            fail("Test 2: IndexOutOfBoundsException expected.");
        } catch (IndexOutOfBoundsException e) {
            // Expected. 
        } 
 
        try { 
            fw.write(buffer, 10, 1);
            fail("Test 3: IndexOutOfBoundsException expected.");
        } catch (IndexOutOfBoundsException e) {
            // Expected. 
        } 
    }