一尘不染

如何将Writer转换为String

java

 Writer writer = new Writer();
 String data = writer.toString();/* the value is not casting and displaying null...*/

还有其他方法可以将writer转换为字符串吗?


阅读 324

收藏
2020-12-03

共1个答案

一尘不染

如果我想用它来制作一个String,我会聘请专门的作家。

Writer writer = new StringWriter();
String data = writer.toString(); // now it works fine
2020-12-03