StringWriter append(CharSequence csq) StringWriter append(char c) StringWriter append(CharSequence csq, int start, int end) 描述 所述java.io.StringWriter.append()方法将指定字符序列到此writer。 声明 以下是java.io.StringWriter.append()方法的声明。 public StringWriter append(CharSequence csq) 参数 csq - 要追加的字符序列。如果csq为null,则将四个字符“null”附加到此writer。 返回值 此方法返回此writer。 异常 NA 实例 以下示例显示了java.io.StringWriter.append()方法的用法。 package com.tutorialspoint; import java.io.*; public class StringWriterDemo { public static void main(String[] args) { // create a new writer StringWriter sw = new StringWriter(); // create two new sequences CharSequence sq1 = "Hello"; CharSequence sq2 = " World"; // append sequence sw.append(sq1); // print result System.out.println("" + sw.toString()); // append second sequence sw.append(sq2); // print result again System.out.println("" + sw.toString()); } } 让我们编译并运行上面的程序,这将产生以下结果 Hello Hello World StringWriter append(char c) StringWriter append(CharSequence csq, int start, int end)