Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

e.printStackTrace();  RSS feed

 
raghavender rao
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ther,

i want to convert store stackTrace into a string is it possible if yes please let me kn
like String s = e.printStackTrace(PrintStream pout);
i kn tht printStackTrace returns void but still i want to store the exception into a String.....
Please help me...

Rao
 
Bill Hause
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way to convert an Exception's stack trace to a string:
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String s = sw.toString();

------------------
 
raghavender rao
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


thanks Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!