Writer append(CharSequence csq) Writer append(char c) Writer append(CharSequence csq, int start, int end) 描述 所述java.io.Writer.append(CSQ CharSequence)方法将指定字符序列到此writer。 声明 以下是java.io.Writer.append()方法的声明。 public Writer append(CharSequence csq) 参数 csq - 要追加的字符序列。如果csq为null,则将四个字符“null”附加到此writer。 返回值 此方法返回此writer。 异常 IOException - 如果发生I / O错误。 实例 以下示例显示了java.io.Writer.append()方法的用法。 package com.tutorialspoint; import java.io.*; public class WriterDemo { public static void main(String[] args) { CharSequence csq = "Hello World!"; // create a new writer Writer writer = new PrintWriter(System.out); try { // append a sequence and change line writer.append("This is an example\n"); // flush the writer writer.flush(); // append a new sequence writer.append(csq); // flush the writer to see the result writer.flush(); } catch (IOException ex) { ex.printStackTrace(); } } } 让我们编译并运行上面的程序,这将产生以下结果 This is an example Hello World! Writer append(char c) Writer append(CharSequence csq, int start, int end)