打印流
print打印流会将基本数据类型格式化成字符串输出,对象则直接调用tostring方法
print和println是打印流的实例
实现文件复制更加简单,因为缓冲流只能写入string类型
package com.study02;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;
public class Print {
public static void main(String[] args) {
PrintStream ps = System.out;
ps.print("aaaaaaaaa");
PrintStream pss = System.err;
pss.println(new Date(100000));
try {
PrintStream ps1 = new PrintStream(new FileOutputStream("e.txt"));
ps1.print("aaaaaaaaaaaaa");
ps1.println("aaaaaaaaaaaaa");
ps1.println("aaaaaaaaaaaaa");
ps1.print("aaaaaaaaaaaaa");
ps1.print("aaaaaaaaaaaaa");
ps1.flush();//需要刷新
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}