CharArrayWriter.close() has the following syntax.
public void close()
In the following code shows how to use CharArrayWriter.close() method.
/* w w w. jav a 2 s. c om*/ 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.