How to convert Writer to String

后端 未结 3 1464
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 02:25
 Writer writer = new Writer();
 String data = writer.toString();/* the value is not casting and displaying null...*/

Is there any other way to convert

3条回答
  •  难免孤独
    2021-02-05 03:14

    I would use a specialized writer if I wanted to make a String out of it.

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

提交回复
热议问题