PrintStream append(CharSequence csq)
描述 (Description)
java.io.PrintStream.append()方法将指定的字符序列追加到此输出流。
声明 (Declaration)
以下是java.io.PrintStream.append()方法的声明。
public PrintStream append(CharSequence csq)
参数 (Parameters)
csq - 要追加的字符序列。 如果csq为null,则将四个字符“null”附加到此输出流。
返回值 (Return Value)
此方法返回此输出流。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.io.PrintStream.append()方法的用法。
package com.iowiki;
import java.io.*;
public class PrintStreamDemo {
public static void main(String[] args) {
String s = "Hello World. ";
// create printstream object
PrintStream ps = new PrintStream(System.out);
// append our strings
ps.append(s);
ps.append("This is an example.");
// print the result
ps.flush();
ps.close();
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Hello World. This is an example.