Java 初学者-javaIO9
今天学习了什么?
今天学习了java的PrintStream类。

import java.io.*; public class PrintStreamTest { //标准输出流 public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub System.out.println("Hello 1"); // PrintStream ps=null;空指针异常 PrintStream ps=System.out; ps.println("hello"); //标准输出流不需要手动close()关闭 //System.gc(); //System.currentTimeMillis(); //System.arraycopy(src, srcPos, dest, destPos, length); //标准输出流不在指向控制台,指向log文件 PrintStream pst=new PrintStream(new FileOutputStream("log.txt"));//log文件在项目下 System.setOut(pst);//pst流可能被关闭 //System.out被重定向输出到文件 System.out.println("hello"); } }
明天学习什么?
明天继续学习javaIO操作。