StringWriter.getBuffer() has the following syntax.
public StringBuffer getBuffer()
In the following code shows how to use StringWriter.getBuffer() method.
//from w w w . j av a 2s .c o m import java.io.*; public class Main { public static void main(String[] args) { StringWriter sw = new StringWriter(); // write a string sw.write("tutorial from java2s.com"); // print result by getting the buffer System.out.println("" + sw.getBuffer()); } }
The code above generates the following result.