@Test public void testGetStackTrace() { final String expectedStackTrace = "java.lang.RuntimeException: Test"; final Throwable t = new RuntimeException("Test"); final String trace = StringUtil.getStackTrace(t); if ( !trace.startsWith(expectedStackTrace) ) { fail("Stack trace: \n" + trace + "\n did not match expected stack trace: \n" + expectedStackTrace); } }
public static String getStackTrace( final Throwable t ) { final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); t.printStackTrace(pw); pw.close(); return bas.toString(); }
StringUtil { public static String getStackTrace( final Throwable t ) { final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); t.printStackTrace(pw); pw.close(); return bas.toString(); } }
StringUtil { public static String getStackTrace( final Throwable t ) { final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); t.printStackTrace(pw); pw.close(); return bas.toString(); } private  StringUtil(); }
StringUtil { public static String getStackTrace( final Throwable t ) { final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); t.printStackTrace(pw); pw.close(); return bas.toString(); } private  StringUtil(); static String join(Collection<String> strings, String delimiter); static String toString( final Object[] array, final String delim ); static String toString( final Object[] array, final String delim, boolean includeBrackets); static String toString( final Object[] array ); static List<String> split(String str, String splitter); static String replace(String source, String search, String replace); static String replaceAll(String source, String search, String replace); static List<String> getTokens(String str, String delimiter); static String getLastToken(String str, String delimiter); static String getFirstToken(String str, String delimiter); static String getStackTrace( final Throwable t ); static boolean isEmpty(final String text); static int indexOfIgnoreCase(final String text, final String str); static boolean startsWithIgnoreCase(final String text, final String prefix); static boolean endsWithIgnoreCase(final String text, final String suffix); static boolean isLetter(char c); static boolean isDigit(char c); static boolean isLetterOrDigit(char c); @SuppressWarnings("unchecked") static T valueOf(String value, Class type); static boolean equalsIgnoreCase(String s1, String s2); static T caseInsensitiveValueOf(Class<T> enumType, String name); static List<String> tokenize(String str, char delim); static String unescape(CharSequence string, int quoteChar, boolean useAsciiEscapes, StringBuilder sb); }
StringUtil { public static String getStackTrace( final Throwable t ) { final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); t.printStackTrace(pw); pw.close(); return bas.toString(); } private  StringUtil(); static String join(Collection<String> strings, String delimiter); static String toString( final Object[] array, final String delim ); static String toString( final Object[] array, final String delim, boolean includeBrackets); static String toString( final Object[] array ); static List<String> split(String str, String splitter); static String replace(String source, String search, String replace); static String replaceAll(String source, String search, String replace); static List<String> getTokens(String str, String delimiter); static String getLastToken(String str, String delimiter); static String getFirstToken(String str, String delimiter); static String getStackTrace( final Throwable t ); static boolean isEmpty(final String text); static int indexOfIgnoreCase(final String text, final String str); static boolean startsWithIgnoreCase(final String text, final String prefix); static boolean endsWithIgnoreCase(final String text, final String suffix); static boolean isLetter(char c); static boolean isDigit(char c); static boolean isLetterOrDigit(char c); @SuppressWarnings("unchecked") static T valueOf(String value, Class type); static boolean equalsIgnoreCase(String s1, String s2); static T caseInsensitiveValueOf(Class<T> enumType, String name); static List<String> tokenize(String str, char delim); static String unescape(CharSequence string, int quoteChar, boolean useAsciiEscapes, StringBuilder sb);  }