PrintWriter append(CharSequence csq, int start, int end)
描述 (Description)
java.io.PrintWriter.append()方法将指定字符序列的子序列附加到此writer。
声明 (Declaration)
以下是java.io.PrintWriter.append()方法的声明。
public PrintWriter append(CharSequence csq,int start,int end)
参数 (Parameters)
csq - 要追加的字符序列。 如果csq为null,则将四个字符“null”附加到此writer。
start - 子序列中第一个字符的索引。
end - 子序列中最后一个字符后面的字符索引。
返回值 (Return Value)
此方法返回此writer。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.io.PrintWriter.append()方法的用法。
package com.iowiki;
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, 1, 3);
pw.append(sq2, 1, 4);
// flush the writer
pw.flush();
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
elWor