common_helper/src/main/java/com/xiongyingqi/util/StackTraceHelper.java
public static void printStackTrace() {
        Throwable throwable = new Throwable();
        StackTraceElement[] stackTraceElements = throwable.getStackTrace();
        StackTraceElement[] stackTraceElementsTarget = new StackTraceElement[stackTraceElements.length - 1];
        // for (int i = 1, j = 0; i < stackTraceElements.length; i++) {
        // StackTraceElement stackTraceElement = stackTraceElements[i];
        // System.out.println(stackTraceElement.getClassName());
        // System.out.println(stackTraceElement.getFileName());
        // System.out.println(stackTraceElement.getMethodName());
        // System.out.println(stackTraceElement.getLineNumber());
        // System.out.println("    at " + stackTraceElement.getClassName() + "."
        // + stackTraceElement.getMethodName() + "(" +
        // stackTraceElement.getFileName() + ":" +
        // stackTraceElement.getLineNumber() + ")");
        // }
        System.arraycopy(stackTraceElements, 1, stackTraceElementsTarget, 0,
                stackTraceElementsTarget.length);
        System.out.println(" ----------------------- StackTrace Info ----------------------- ");
        System.out.print(buildStackTrace(stackTraceElementsTarget));
    }
public static void printStackTrace() {
        Throwable throwable = new Throwable();
        StackTraceElement[] stackTraceElements = throwable.getStackTrace();
        StackTraceElement[] stackTraceElementsTarget = new StackTraceElement[stackTraceElements.length - 1];
        // for (int i = 1, j = 0; i < stackTraceElements.length; i++) {
        // StackTraceElement stackTraceElement = stackTraceElements[i];
        // System.out.println(stackTraceElement.getClassName());
        // System.out.println(stackTraceElement.getFileName());
        // System.out.println(stackTraceElement.getMethodName());
        // System.out.println(stackTraceElement.getLineNumber());
        // System.out.println("    at " + stackTraceElement.getClassName() + "."
        // + stackTraceElement.getMethodName() + "(" +
        // stackTraceElement.getFileName() + ":" +
        // stackTraceElement.getLineNumber() + ")");
        // }
        System.arraycopy(stackTraceElements, 1, stackTraceElementsTarget, 0,
                stackTraceElementsTarget.length);
        System.out.println(" ----------------------- StackTrace Info ----------------------- ");
        System.out.print(buildStackTrace(stackTraceElementsTarget));
    }
public static void printStackTrace ( ) { Throwable throwable = new Throwable ( ) ; StackTraceElement [ ] stackTraceElements = throwable . getStackTrace ( ) ; StackTraceElement [ ] stackTraceElementsTarget = new StackTraceElement [ stackTraceElements . length - 1 ] ; // for (int i = 1, j = 0; i < stackTraceElements.length; i++) { // StackTraceElement stackTraceElement = stackTraceElements[i]; // System.out.println(stackTraceElement.getClassName()); // System.out.println(stackTraceElement.getFileName()); // System.out.println(stackTraceElement.getMethodName()); // System.out.println(stackTraceElement.getLineNumber()); // System.out.println("    at " + stackTraceElement.getClassName() + "." // + stackTraceElement.getMethodName() + "(" + // stackTraceElement.getFileName() + ":" + // stackTraceElement.getLineNumber() + ")"); // } System . arraycopy ( stackTraceElements , 1 , stackTraceElementsTarget , 0 , stackTraceElementsTarget . length ) ; System . out . println ( " ----------------------- StackTrace Info ----------------------- " ) ; System . out . print ( buildStackTrace ( stackTraceElementsTarget ) ) ; }
打印出调用堆栈 <br>
2013-8-28 下午3:52:17
打印出调用堆栈 <br > 2013 - 8 - 28 下午3 : 52 : 17