Code example for CharArrayWriter

Methods: toCharArraytoStringwrite

0
 
    /** 
     * @tests java.io.CharArrayWriter#toString() 
     */ 
    public void test_toString() { 
        cw.write("HelloWorld", 5, 5);
        cr = new CharArrayReader(cw.toCharArray());
        assertEquals("Returned incorrect string", "World", cw.toString());
    } 
 
    /** 
     * @tests java.io.CharArrayWriter#write(char[], int, int) 
     */ 
    public void test_write$CII() throws IOException { 
        cw.write(hw, 5, 5);
        cr = new CharArrayReader(cw.toCharArray());
        char[] c = new char[100];
        cr.read(c, 0, 5);
        assertEquals("Writer failed to write correct chars", "World",
                new String(c, 0, 5));
    }