package JBJADV003;
import java.io.*;public class ReOut {/**
* @param args */ public static void main(String[] args) { PrintStream ps=null; try{ //创建PrintStream输出流 ps=new PrintStream(new FileOutputStream("c:\\myDoc\\hello.txt")); //重定向到文件 System.setOut(ps); //向文件print内容 System.out.print("我的测试,重定向到文件hello!"); System.out.println(new ReOut()); }catch(IOException ex){ }finally{ if(ps!=null){ ps.close(); } } }}