Here you can find the source of stackTraceStr(Exception e)
public static String stackTraceStr(Exception e)
//package com.java2s; /*/*w w w . ja v a 2 s . com*/ * Util.java - A utility codes. * * Copyright (c) 2016 National Institute of Information and Communications * Technology, Japan * * You can redistribute it and/or modify it under either the terms of * the AGPLv3 or PIAX binary code license. See the file COPYING * included in the PIQT package for more in detail. */ import java.io.PrintWriter; import java.io.StringWriter; public class Main { static public String newline = System.lineSeparator(); public static String stackTraceStr(Exception e) { String ret = ""; String msg = e.getMessage(); if (msg != null) { ret += msg + newline; } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); pw.flush(); ret += sw.toString(); return ret; } }