Below code snippet shows how to convert a Exception Stack Trace to String object in Java
public static String convertExStackTraceToString(Exception ex)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
sw.flush();
String strStackTrace = sw.toString();
try
{
sw.close();
pw.close();
}catch (IOException ex1)
{
ex1.printStackTrace();
}
return strStackTrace;
}
No comments:
Post a Comment