import java.io.BufferedOutputStream;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class TestPrintStream {
/**
* @param args
*/
public static void main(String[] args) {
try {
FileOutputStream fos=new FileOutputStream("d:/wdl.txt");
PrintStream ps=new PrintStream(fos);
System.setOut(ps); //重定向标准输出到文件
int count=0;
for(char i=0;i<65535;i++){
System.out.print(i+" "); //输出全部unicode字符
if(count++>=100){
System.out.println();
count=0;
}
}
fos.close();
ps.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out); //恢复标准输出(控制台)
System.setOut(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
System.out.print("ok!");
}
}