Code example for CharArrayWriter

Methods: appendcloseflushtoString

0
    public void test_appendChar() throws IOException { 
        char testChar = ' ';
        CharArrayWriter writer = new CharArrayWriter(10);
        writer.append(testChar);
        writer.flush();
        assertEquals(String.valueOf(testChar), writer.toString());
        writer.close();
    } 
 
    /** 
     * @tests java.io.CharArrayWriter#append(CharSequence) 
     */ 
    public void test_appendCharSequence() { 
        String testString = "My Test String";
        CharArrayWriter writer = new CharArrayWriter(10);
        writer.append(testString);
        writer.flush();
        assertEquals(testString, writer.toString());
        writer.close();
    } 
Experience pair programming with AI  Get Codota for Java