|
-
September 15th, 2000, 06:46 AM
#1
redirect Throwable.printStackTrace()...
basicly i want to redirect the the Throwable.printStackTrace() / printStackTrace(PrintStream) / printStackTrace(PrintWriter) to a String / StringBuffer instead of System.err.
Does anyone know how to do this? plz help 
-
September 15th, 2000, 11:37 AM
#2
Re: redirect Throwable.printStackTrace()...
There is the System.setErr(PrintStream) method that will change the StdErr to go to a PrintStream. Then that PrintStream could be a connected to a StringWriter.
Norm
-
September 16th, 2000, 08:25 AM
#3
Thanks!
Finally got it to work. Here's the code if someone else needs it...
try
{
...
}
catch(Throwable e)
{
StringWriter errorBuffer = new StringWriter();
e.printStackTrace(new PrintWriter(errorBuffer));
}
errorBuffer now contains the stacktrace in memory, and you can do whatever you want with it 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|