Here you can find the source of getStackTrace(Throwable ex)
private static StringTokenizer getStackTrace(Throwable ex)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.StringTokenizer; public class Main { private static final String LINE_BREAKING = System.lineSeparator(); private static StringTokenizer getStackTrace(Throwable ex) { ByteArrayOutputStream temp = new ByteArrayOutputStream(); ex.printStackTrace(new PrintStream(temp)); String stackTrace = new String(temp.toByteArray()); return new StringTokenizer(stackTrace, LINE_BREAKING); }// w ww.j a va 2 s .c om }