Get Stacktrace as String

  • Antworten:0
Mac Systems
  • Forum-Beiträge: 1.727

24.07.2010, 17:17:37 via Website

1/**
2 * Returns a Throwable as a String, if Throwable is null the String "null"
3 * will be returned.
4 *
5 * @param aThrowable
6 * @return
7 */
8 public static String getStackTrace(final Throwable aThrowable)
9 {
10 if (aThrowable == null)
11 {
12 return "null";
13 }
14 final Writer result = new StringWriter();
15 final PrintWriter printWriter = new PrintWriter(result);
16 aThrowable.printStackTrace(printWriter);
17 return result.toString();
18 }

- Mac

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten