Java.io.StringWriter.flush() 方法


Java.io.StringWriter.flush() 方法

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);



      // flush the writer

      sw.flush();



      // print result

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



   }

}