Java.io.StringWriter.toString() 方法


Java.io.StringWriter.toString() 方法

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 converting to string

      System.out.println("" + sw.toString());



   }

}