Code example for CharArrayWriter

Methods: toCharArraywrite

0
 
    /** 
     * @tests java.io.CharArrayWriter#toCharArray() 
     */ 
    public void test_toCharArray() throws IOException { 
        cw.write("HelloWorld", 0, 10);
        cr = new CharArrayReader(cw.toCharArray());
        char[] c = new char[100];
        cr.read(c, 0, 10);
        assertEquals("toCharArray failed to return correct array",
                "HelloWorld", new String(c, 0, 10));
    } 
 
    /** 
     * @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());
Contextual code suggestions in your IDE  Get Codota for Java