Java IO: StringWriter
StringWriter class enables you to obtain the characters written to a
String. Here is a simple example:
StringWriter writer = new StringWriter(); //write characters to writer. String data = writer.toString(); StringBuffer dataBuffer = writer.getBuffer();
toString() returns the characters written to the
getBuffer() returns the
used by the
StringWriter to build the string from the written characters.