What is the correct way to \"empty\" a StringWriter in Java so that I can reuse the StringWriter without having to create a new one? Neither StringWriter.flush
StringWriter
Alternatively, we could also delete the buffer using the following code:
StringBuffer buf = ****.getBuffer(); buf.delete(0,buf.length());
How about calling getBuffer().setLength(0)?
getBuffer().setLength(0)