Java CharArrayWriter.size()

Syntax

CharArrayWriter.size() has the following syntax.

public int size()

Example

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


//w w w. j  a v a  2  s. co m
import java.io.CharArrayWriter;

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

    String str = "from java2s.com!";

    CharArrayWriter chw = new CharArrayWriter();

    // create destination character array writer
    CharArrayWriter chwd = new CharArrayWriter();

    chw.write(str);

    chw.writeTo(chwd);

    // print the destination buffer content as string
    System.out.println(chwd.toString());
    System.out.println(chwd.size());

  }
}

The code above generates the following result.