标准输出流
package com;
import java.io.*;
public class test {
public static void main(String[] args) throws FileNotFoundException {
//联合起来写
System.out.println("HelloWorld");
//分开写
PrintStream ps = System.out;
ps.println("zs");
ps.println("lisi");
ps.println("ww");
//标准输出的流不需要close()
//可以改变标准的输出的方向吗?可以
//之前使用的方法和属性
/**
System.gc();
System.currentTimeMillis();
PrintStream out = System.out;
System.exit(0);
System.arraycopy(...)
*/
//标准输出流不指向控制台,指向log文件
PrintStream printStream = new PrintStream(new FileOutputStream("log"));
//修改输出方向,将输出的方向修改到log文件
System.setOut(printStream);
//再输出
System.out.println("HelloWorld");
System.out.println("Hello kitty");//这2行输出到文件里了
}
}