Java.io.StringWriter.getBuffer() 方法 Java.io.StringWriter.flush() 方法 Java.io.StringWriter.toString() 方法 Java.io.StringWriter.getBuffer() 方法 package com.codingdict; import java.io.*; public class StringWriterDemo { public static void main(String[] args) { // create a new writer StringWriter sw = new StringWriter(); // write a string sw.write("Hello World"); // print result by getting the buffer System.out.println("" + sw.getBuffer()); } } Java.io.StringWriter.flush() 方法 Java.io.StringWriter.toString() 方法