UnsafeStringWriter extends Writer { @Override public Writer append(CharSequence csq) { if (csq == null) { write("null"); } else { write(csq.toString()); } return this; } UnsafeStringWriter();  UnsafeStringWriter(int size); @Override void write(int c); @Override void write(char[] cs); @Override void write(char[] cs, int off, int len); @Override void write(String str); @Override void write(String str, int off, int len); @Override Writer append(CharSequence csq); @Override Writer append(CharSequence csq, int start, int end); @Override Writer append(char c); @Override void close(); @Override void flush(); @Override String toString();  }
@Test public void testAppend() { UnsafeStringWriter writer = new UnsafeStringWriter(); writer.append("a"); writer.append("abc", 1, 2); writer.append('c'); writer.flush(); writer.close(); assertThat(writer.toString(), is("abc")); }