×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: digas
Added: Sep 26, 2014 2:50 PM
Views: 15
Tags: no tags
  1.  
  2. StringWriter stringWriter = new StringWriter();
  3. PrintWriter printWriter = new PrintWriter(stringWriter);
  4. ex.printStackTrace(printWriter);
  5. String stackTrace = stringWriter.toString();
  6.  
  7. or :
  8.  
  9.  if you are already using apache commons lang in your project, use the getStackTrace method in the ExceptionUtils class
  10.  
  11. org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(Throwable)