62,623
社区成员
发帖
与我相关
我的任务
分享
package com.justdoit.io;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class TestPrintStream1 {
public static void main(String[] args) {
PrintStream ps = null;
try {
FileOutputStream fos = new FileOutputStream("d:\\log.dat");
ps = new PrintStream(fos);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(ps!=null){
System.setOut(ps);
}
int length = 0;
for(char c =0;c<=1000;c++){
System.out.print(c+" ");
if(length++>100){
System.out.println();
length=0;
}
}
}
}