Java CharArrayWriter.close()

Syntax

CharArrayWriter.close() has the following syntax.

public void close()

Example

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


/* w w w . j a  va2 s . com*/


import java.io.CharArrayWriter;

public class Main {
  public static void main(String[] args) {


    CharArrayWriter chw = new CharArrayWriter();

    CharSequence csq = "java2s.com";

    // closes the stream
    chw.close();

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

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

  }
}

The code above generates the following result.