UnsyncStringWriter extends Writer { @Override public String toString() { if (_stringBundler != null) { return _stringBundler.toString(); } return _stringBuilder.toString(); } UnsyncStringWriter();  UnsyncStringWriter(boolean useStringBundler);  UnsyncStringWriter(boolean useStringBundler, int initialCapacity);  UnsyncStringWriter(int initialCapacity); @Override UnsyncStringWriter append(char c); @Override UnsyncStringWriter append(CharSequence charSequence); @Override UnsyncStringWriter append(
		CharSequence charSequence, int start, int end); @Override void close(); @Override void flush(); StringBuilder getStringBuilder(); StringBundler getStringBundler(); void reset(); @Override String toString(); @Override void write(char[] chars); @Override void write(char[] chars, int offset, int length); @Override void write(int c); @Override void write(String string); @Override void write(String string, int offset, int length);  }
@Test public void testToString() throws Exception { UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(false); StringBuilder stringBuilder = (StringBuilder)_stringBuilderField.get( unsyncStringWriter); Assert.assertNotNull(stringBuilder); Assert.assertNull(_stringBundlerField.get(unsyncStringWriter)); unsyncStringWriter.append('a'); Assert.assertEquals(1, stringBuilder.length()); Assert.assertEquals("a", unsyncStringWriter.toString()); unsyncStringWriter.append('b'); Assert.assertEquals(2, stringBuilder.length()); Assert.assertEquals("ab", unsyncStringWriter.toString()); unsyncStringWriter = new UnsyncStringWriter(); StringBundler stringBundler = (StringBundler)_stringBundlerField.get( unsyncStringWriter); Assert.assertNull(_stringBuilderField.get(unsyncStringWriter)); Assert.assertNotNull(stringBundler); unsyncStringWriter.append('a'); Assert.assertEquals(1, stringBundler.index()); Assert.assertEquals("a", unsyncStringWriter.toString()); unsyncStringWriter.append('b'); Assert.assertEquals(2, stringBundler.index()); Assert.assertEquals("ab", unsyncStringWriter.toString()); }