Java IO Tutorial - Java CharArrayWriter(int initialSize) Constructor








Syntax

CharArrayWriter(int initialSize) constructor from CharArrayWriter has the following syntax.

public CharArrayWriter(int initialSize)

Example

In the following code shows how to use CharArrayWriter.CharArrayWriter(int initialSize) constructor.

//from w w  w .  j  a  v  a2  s  . c o  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(100);


    chw.write(str);
  
    System.out.println(chw.toString());

  }
}

The code above generates the following result.