第一种办法可以通过字符串,也就是先把错误信息写入字符串,再将字符串写入文件 import java.io.*; public class Demo { public static void main(String[] args) throws Exception{ try{ throw new Exception(); }catch(Exception e){ StringWriter writer = new StringWriter(); e.printStackTrace(new Prin
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Diagnostics; namespace CSharpIOTest { class Program { static void Main(string[] args) { string file = @"I:\computer_info.cfg"; if
在做批量实验室,例如跑批量MR的作业,我们会写好shell脚本,然后启动脚本,等所有作业执行完再去看结果,但是这些执行时的信息如何保存下来到文件中呢?下面这个命令可以完成这个任务. sh batchjob.sh 2>&1 | tee mylog.log 其中sh batchjob.sh:表示要执行的shell脚步:0,1,2:在linux分别表示标准输入.标准输出和标准错误信息输出. 下面来总结下重定向问题. 输入输出重定向之:'<' and '>' '<' and '&g