File file = new File("D:\\home\\tomcat\\logs\\app1.log");
FileOutputStream fileOutputStream = new FileOutputStream(file, true);
e.printStackTrace(new PrintStream(fileOutputStream));
FileOutputStream 的构造函数,第二个参数表示是否在文件原内容上追加,默认是否,会把原文件的内容直接覆盖。
设置为 true 的话,输出流写文件的时候,会在原文件的内容基础上进行追加。