简单日志的生成?????????????????????????????????????????????????????????
我用以下方法生成简单的日志,可是每次新生成的日志都会覆盖旧的日志,如何才能让新生成的日志追加到文件末尾而不覆盖新的日志呢?
String str = "abcd";
PrintStream out = new PrintStream("f:/test.txt");
System.setOut(out);
System.out.println(str);
------解决方案--------------------把这句: PrintStream out = new PrintStream("f:/test.txt");
改成:PrintStream ps = new PrintStream(new FileOutputStream("f:/test.txt",true));即可!
如:
PrintStream("f:/test.txt");
String s = "ddddddddddddddddd";
PrintStream ps = new PrintStream(new FileOutputStream("f:/test.txt",true));
System.setOut(ps);
System.out.println(s);
------解决方案--------------------PrintStream ps = new PrintStream(new FileOutputStream("f:/test.txt",true));即可
------解决方案--------------------