Java.io.StringWriter.close() 方法 Java.io.StringWriter.append() 方法 Java.io.StringWriter.flush() 方法 Java.io.StringWriter.close() 方法 package com.codingdict; import java.io.*; public class StringWriterDemo { public static void main(String[] args) { // create a new writer StringWriter sw = new StringWriter(); // create a new sequence String s = "Hello world"; // write a string sw.write(s); // print result System.out.println("" + sw.toString()); try { // close the writer sw.close(); } catch (IOException ex) { ex.printStackTrace();; } } } Java.io.StringWriter.append() 方法 Java.io.StringWriter.flush() 方法