Java.io.PrintWriter.println() 方法
描述
java.io.PrintWriter.println() 方法通过写入行分隔符字符串来终止当前行。 行分隔符字符串由系统属性 line.separator 定义,不一定是单个换行符 ('\n')。
声明
以下是 java.io.PrintWriter.println() 方法的声明。
public void println()
参数
NA
返回值
此方法不返回值。
异常
NA
示例
下面的例子展示了 java.io.PrintWriter.println() 方法的使用。
package com.tutorialspoint;
import java.io.*;
public class PrintWriterDemo {
public static void main(String[] args) {
String s = "Hello world.";
// create a new writer
PrintWriter pw = new PrintWriter(System.out);
// print string
pw.print(s);
// change the line twice
pw.println();
pw.println();
// print another string
pw.print("Two lines skipped.");
// flush the writer
pw.flush();
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Hello world. Two lines skipped.

