Here you can find the source of printStackTrace(Exception e)
public static String printStackTrace(Exception e)
//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(); } }