import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;

public class SystemOutTest {
    public static void main(String[] args) throws Exception {
        String property = System.getProperties().getProperty("user.home");
        String filePath = property.replace("\\", "/");
        String fileName = filePath + "/out.txt";
        try {
            System.setOut(new PrintStream(new FileOutputStream(fileName)));
            while (true) {
                Thread.sleep(5000);
                System.out.println(new Date());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2021-09-28
猜你喜欢
  • 2021-08-17
  • 2021-08-17
  • 2021-12-22
  • 2021-06-21
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案