import java.io.File; import java.io.IOException; import java.io.FileOutputStream; import java.io.PrintStream; public class B { public static void main(String[] args)throws IOException { File f=new File("e://out.txt"); FileOutputStream fileOutputStream = new FileOutputStream(f); PrintStream printStream = new PrintStream(fileOutputStream); System.setOut(printStream); System.out.println("默认输出到了文件 out.txt"); } }