🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Java - `Writer`到`String`的转换 > 原文: [https://beginnersbook.com/2015/05/java-writer-to-string-conversion/](https://beginnersbook.com/2015/05/java-writer-to-string-conversion/) ```java package com.beginnersbook.string; import java.io.StringWriter; public class WriterToString {     public static void main(String args[]){         // create a new writer           StringWriter sw = new StringWriter();           // append a char                  sw.append("abc");           sw.append(" xyz");           String str = sw.toString();           System.out.println(str);     } } ``` **输出:** ```java abc xyz ```