Here you can find the source of getStackTraceChain(Throwable t, String[] allow, String[] deny)
public static StackTraceElement[][] getStackTraceChain(Throwable t, String[] allow, String[] deny)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /**//from www. ja va2 s .c o m * Returns stack trace chain filtered by class names. */ public static StackTraceElement[][] getStackTraceChain(Throwable t, String[] allow, String[] deny) { ArrayList<StackTraceElement[]> result = new ArrayList<StackTraceElement[]>(); while (t != null) { StackTraceElement[] stack = getStackTrace(t, allow, deny); result.add(stack); t = t.getCause(); } StackTraceElement[][] allStacks = new StackTraceElement[result .size()][]; for (int i = 0; i < allStacks.length; i++) { allStacks[i] = result.get(i); } return allStacks; } /** * Returns stack trace filtered by class names. */ public static StackTraceElement[] getStackTrace(Throwable t, String[] allow, String[] deny) { StackTraceElement[] st = t.getStackTrace(); ArrayList<StackTraceElement> result = new ArrayList<StackTraceElement>( st.length); elementLoop: for (StackTraceElement element : st) { String className = element.getClassName(); if (allow != null) { boolean validElemenet = false; for (String filter : allow) { if (className.indexOf(filter) != -1) { validElemenet = true; break; } } if (validElemenet == false) { continue; } } if (deny != null) { for (String filter : deny) { if (className.indexOf(filter) != -1) { continue elementLoop; } } } result.add(element); } st = new StackTraceElement[result.size()]; return result.toArray(st); } }