Code example for StringWriter

Methods: appendclosetoString

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