Java tutorial
import java.io.CharArrayWriter; public class Main { public static void main(String[] args) throws Exception { CharArrayWriter chw = new CharArrayWriter(); String str = "from java2s.com!"; chw.write(str); // get array of character from the writer char[] ch = chw.toCharArray(); // for each character in character array for (char c : ch) { // print character System.out.println(c); } } }