import java.io.*;
public class IO2File {
    public static void main(String[] args) throws IOException {
        File f=new File("out.txt");
        f.createNewFile();
        FileOutputStream fileOutputStream = new FileOutputStream(f);
        PrintStream printStream = new PrintStream(fileOutputStream);
        System.setOut(printStream);
        System.out.println("默认输出到控制台的这一句,输出到了文件 out.txt");
    }
}

 

 


相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
猜你喜欢
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2021-05-29
  • 2022-02-06
相关资源
相似解决方案