学习笔记之—PrintStackTrace方法

public class PrintStackTrace {
    public static void myPrintStackTrace(Throwable th){
        System.out.println(th);
        //System.err.println(th.getClass().getName()+": "+th.getMessage());
        StackTraceElement[] st = th.getStackTrace();
        for(StackTraceElement s:st)
            System.out.println("\tat "+s.getClassName()+"."+s.getMethodName()+"("+s.getFileName()+":"
                    +s.getLineNumber()+")");
    }
}

这个方法打印后顺序会有变化这与IO流有关,还得多研究下源码

posted on 2015-10-25 14:09  托马斯不拖马  阅读(1508)  评论(0编辑  收藏  举报

导航