• Post Reply Bookmark Topic Watch Topic
  • New Topic

e.printStackTrace();

 
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 the printStackTrace returns void but still i want to store the exception into a String.....
Please help me...

Rao
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rao,
Following Code will do the needful
StringWriter exception1=new StringWriter();
e.printStackTrace(new PrintWriter(exception1));
String exceptionInString = exception1.toString();
-Harneet Sachdeva
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harneet --
Welcome to JavaRanch!
We don't have too many rules around here, but we do have our naming policy, which requires you to use a first and last name. Please head over here and fix yours, pronto. Thanks, pardner -- see you around the Ranch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!