Java.io.PrintWriter.append( CharSequence csq ) 方法
描述
java.io.PrintWriter.append() 方法将指定的字符序列附加到这个 writer。
声明
以下是 java.io.PrintWriter.append() 方法的声明。
public PrintWriter append(CharSequence csq)
参数
csq − 要追加的字符序列。 如果 csq 为 null,则将四个字符"null"附加到此 writer。
返回值
此方法返回此 writer。
异常
NA
示例
下面的例子展示了 java.io.PrintWriter.append() 方法的使用。
package com.tutorialspoint;
import java.io.*;
public class PrintWriterDemo {
public static void main(String[] args) {
CharSequence sq1 = "Hello";
CharSequence sq2 = " World";
// create a new stream at system
PrintWriter pw = new PrintWriter(System.out);
// append the sequence
pw.append(sq1);
pw.append(sq2);
// flush the writer
pw.flush();
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Hello World

