将System.out输出在控制台的信息保存在文件中
2018-07-20 来源:open-open
将当前项目的System.out的输出保存在当前项目下的system.out.txt中
//1.获取项目的目录
Path path = Paths.get(".");
Path resolve = path.resolve("system.out.txt");
System.out.println(resolve.toAbsolutePath().normalize().toString());
//2. 设置
if (resolve !=null) {
//not the best way to debug
OutputStream output = new FileOutputStream(resolve.toAbsolutePath().normalize().toString());
PrintStream printOut = new PrintStream(output);
System.setOut(printOut);
}
//3.测试 system.out.txt中是否有该信息
System.out.println(resolve.toAbsolutePath().normalize().toString());
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:iOS视图淡入淡出效果
下一篇:打开IOS设备的闪光灯代码
最新资讯
热门推荐