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
This commit is contained in:
parent
3e44b6f86f
commit
5176b8f7c2
|
@ -81,7 +81,7 @@ import java.util.Iterator;
|
|||
* @author <a href="mailto:ed@apache.org">Ed Korthof</a>
|
||||
* @author <a href="mailto:rand_mcneely@yahoo.com>Rand McNeely</a>
|
||||
* @author <a href="mailto:scolebourne@joda.org>Stephen Colebourne</a>
|
||||
* @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.
|
||||
* <p>
|
||||
* 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue