Java IO Tutorial - Java CharArrayWriter.flush()








Syntax

CharArrayWriter.flush() has the following syntax.

public void flush()

Example

In the following code shows how to use CharArrayWriter.flush() method.

/* w  w w.ja v  a2s.c  o  m*/
import java.io.CharArrayWriter;

public class Main {
  public static void main(String[] args) {
    CharArrayWriter chw = new CharArrayWriter();

    CharSequence csq = "java2s.com";

    // append character sequence to the writer
    chw.append(csq);

    // flush
    chw.flush();

    // prints out the character sequences
    System.out.println(chw.toString());

  }
}

The code above generates the following result.