code: public static String getStackTrace(Throwable th)
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      th.printStackTrace(pw);
      return sw.toString();
    }
docs: Returns the stack trace of the throwable as a string
  
  @param th the throwable
  @return the stack trace as a string