Java Stacktrace Print printStackTrace(Exception e)

Here you can find the source of printStackTrace(Exception e)

Description

print Stack Trace

License

Open Source License

Declaration

public static String printStackTrace(Exception e) 

Method Source Code

//package com.java2s;
/*/*w ww.  ja  v  a  2s  . c o m*/
 * <pre>
 * Copyright (c) 2014 Samsung SDS.
 * All right reserved.
 *
 * This software is the confidential and proprietary information of Samsung
 * SDS. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license agreement
 * you entered into with Samsung SDS.
 *
 * Author             : Takkies
 * Date                : 2014. 04. 01.
 * Description      : 
 * </pre>
 */

public class Main {

    public static String printStackTrace(Exception e) {
        StringBuilder str = new StringBuilder();
        str.append(e + "\r\n");
        str.append("-----------------------------------------\r\n");
        StackTraceElement[] trace = e.getStackTrace();
        for (int i = 0; i < trace.length; i++) {
            if (trace[i].getLineNumber() == -1)
                continue;
            str.append(trace[i] + "\r\n");
        }
        return str.toString();
    }
}

Related

  1. printStackTrace()
  2. printStackTrace()
  3. printStackTrace()
  4. printStackTrace()
  5. printStackTrace()
  6. printStackTrace(Exception e)
  7. printStackTrace(Exception e)
  8. printStackTrace(Exception e)
  9. printStackTrace(Exception exception)