在Java 1.5中,如何克隆java.io.CharArrayWriter的实例?
CharArrayWriter x = new CharArrayWriter(200);
x.write("foo bar bob");
CharArrayWriter y = x.clone(); // Object.clone() is not visible!!
谢谢,
mobiGeek
最佳答案
没有克隆方法,但是可以使用writeTo
方法。
CharArrayWriter copy = new CharArrayWriter(x.size());
x.writeTo(copy);