全屏
java.io.PrintWriter.println() 方法通过写入行分隔符字符串终止当前行。行分隔符字符串由系统属性line.separator定义,并且不一定是单个换行符(' ').
声明
以下是java.io.PrintWriter.println()方法的声明public void println()
参数NA
返回值
此方法不返回任何值。
异常NA
例子
下面的示例演示java.io.PrintWriter.println()方法的用法。package cn.sxt;
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.
分享到:
0评论