Java IO Tutorial - Java CharArrayWriter.reset()








Syntax

CharArrayWriter.reset() has the following syntax.

public void reset()

Example

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

/*ww w . j a  v  a 2 s  .co 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);


    // print character sequence
    System.out.println(csq);

    // invoke reset()
    chw.reset();

    csq = "1234567890";

    chw.append(csq);
    System.out.println(chw.toString());

  }
}

The code above generates the following result.