Java examples for java.lang:Exception StackTrace
Converts exception stack trace as string
//package com.java2s; import java.io.*; public class Main { /**/*from ww w. j av a 2 s .c om*/ * Converts exception stack trace as string * * @param ex * @return */ public static String toStackStrace(Throwable ex) { try (StringWriter sw = new StringWriter()) { ex.printStackTrace(new PrintWriter(sw)); return sw.toString(); } catch (IOException e) { return e.getMessage(); } } }