📜  java print stacktrace to file - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:33.505000             🧑  作者: Mango

代码示例1
//printStackTrace() can accept PrintWriter or PrintStream as argument
catch (Exception e) {

    PrintWriter pw = new PrintWriter(new File("file.txt"));
    e.printStackTrace(pw);
    pw.close();
}

/*Credits: 
Stackoverflow Users: 
Less (https://stackoverflow.com/users/587318/less)
Qnan (https://stackoverflow.com/users/190670/qnan)*/