首页 > 代码库 > Java基础-重写System.out.println方法

Java基础-重写System.out.println方法

PrintStream myStream = new PrintStream(System.out) {    @Override    public void println(String x) {        super.println(System.currentTimeMillis() + ": " + x);    }};System.setOut(myStream);System.out.println("Hello World!");-------------------------------------------------------------------------------Output:1420553422337: Hello World!

参考:http://stackoverflow.com/questions/27800326/hook-into-system-out-println-and-modify

Java基础-重写System.out.println方法