import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class PrintStreamDemo {
public static void main(String[] args) throws FileNotFoundException {
PrintStream ps =new PrintStream(new FileOutputStream(“D:\JAVA1\src\data7.txt”));//目标文件
System.setOut(ps);//把系统的打印流改成我们自己的打印流
System.out.println("12312123");
}
}