From 5176b8f7c2a6271892961006a4d3a53688cc0771 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Sat, 31 Aug 2002 19:05:32 +0000 Subject: [PATCH] Removed stackTrace and getStackTrace. ExceptionUtils has getStackTrace and stackTrace is only slightly different in that it uses a ByteArrayOutputStream and not a StringWriter. A change since the beta, but not allowing obvious ones to happen will be silly. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137002 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/lang/StringUtils.java | 46 +------------------ 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/src/java/org/apache/commons/lang/StringUtils.java b/src/java/org/apache/commons/lang/StringUtils.java index a519b571f..525b89533 100644 --- a/src/java/org/apache/commons/lang/StringUtils.java +++ b/src/java/org/apache/commons/lang/StringUtils.java @@ -81,7 +81,7 @@ import java.util.Iterator; * @author Ed Korthof * @author Stephen Colebourne - * @version $Id: StringUtils.java,v 1.9 2002/08/31 11:07:08 scolebourne Exp $ + * @version $Id: StringUtils.java,v 1.10 2002/08/31 19:05:32 bayard Exp $ */ public class StringUtils { @@ -1480,29 +1480,6 @@ public class StringUtils { // Misc //-------------------------------------------------------------------------- - - /** - * Get the stack trace from a Throwable as a String. - *

- * This method uses printStackTrace() internally to obtain the stack trace. - * - * @see java.lang.Throwable#printStackTrace() - * @param throwable the throwable to extract a stack trace from - * @return the extracted stack trace, or null if an error occurs - */ - public static String stackTrace(Throwable throwable) { - String trace = null; - try { - // And show the Error Screen. - ByteArrayOutputStream buf = new ByteArrayOutputStream(); - throwable.printStackTrace(new PrintWriter(buf, true)); - trace = buf.toString(); - - } catch (Exception ex) { - // ignore - } - return trace; - } /** * Find the Levenshtein distance between two strings. @@ -1570,27 +1547,6 @@ public class StringUtils { return d[n][m]; } - /** - * Convenient method to retrieve the full stacktrace from a given exception. - * - * @param t the exception to get the stacktrace from. - * @return the stacktrace from the given exception. - */ - public static String getStackTrace(Throwable t) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw, true); - t.printStackTrace(pw); - pw.flush(); - pw.close(); - return sw.toString(); - } - -// these are not really of use in the Java world. Only if you're a C afficionado -// public static String sprintf(String format, Object[] list); -// public static Object[] sscanf(String str, String format); -// public static String pack(String[] strs, String format); -// public static String[] unpack(String str, String format); - }