/*
时间:2015年3月10日20:11:19
目的:测试打印流PrintStream PrintWriter
两个都属于输出流,分别针对字符和字节
两个类的输出操作不会抛出异常,用户通过检查异常的错误状态获取错误信息。
*/
import java.io.*;
public class TestPrintStream1 {
public static void main(String[] args) {
PrintStream ps = null;
FileOutputStream fos = null;
try{
fos = new FileOutputStream("D:/bak/log.dat");
ps = new PrintStream(fos);
if (null != ps) {
System.setOut(ps);//重新分配标准输出流
}
for (int i=0; i<=60000; i++) {
System.out.print((char)i);
}
} catch(FileNotFoundException e) {
e.printStackTrace();
} finally {
try {
ps.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}