将System.out输出在控制台的信息保存在文件中
http://my.oschina.net/ordiychen/blog/600419
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Java代码 //1.获取项目的目录 Path path = Paths.get("."); Path resolve = path.resolve("system.out.txt"); System.out.println(resolve.toAbsolutePath().normalize().toString()); //2. 设置 if (level.getStandardLevel().intLevel() == 600) { //not the best way to debug OutputStream output = new FileOutputStream(resolve.toAbsolutePath().normalize().toString()); PrintStream printOut = new PrintStream(output); System.setOut(printOut); } System.out.println(resolve.toAbsolutePath().normalize().toString());//3.测试 system.out.txt中是否有该信息 |