Code example for CharArrayWriter

Methods: writewriteTo

0
        } 
    } 
 
    public void test_writeToLjava_io_Writer() { 
        Support_ASimpleWriter ssw = new Support_ASimpleWriter(true);
        cw.write("HelloWorld", 0, 10);
        StringWriter sw = new StringWriter();
        try { 
            cw.writeTo(sw);
            assertEquals("Test 1: Writer failed to write correct chars;",
                         "HelloWorld", sw.toString());
        } catch (IOException e) {
            fail("Exception during writeTo test : " + e.getMessage());
        } 
 
        try { 
            cw.writeTo(ssw);
            fail("Test 2: IOException expected.");
        } catch (IOException e) {
            // Expected. 
        } 
    }