dcsimg
wrapping streams and displaying on a JTextArea
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   maarten_storm
Posted On:   Tuesday, April 10, 2001 01:45 PM

I hava a printstream and a FileOutputStream from a server (serverconsole), and whant to display it on a JTextArea. How can I do that?

Re: wrapping streams and displaying on a JTextArea

Posted By:   Ariel_Friedmann  
Posted On:   Wednesday, May 2, 2001 02:19 AM

Here is an answer I saw that was very useful:

import java.io.*;

public class StackTrace {
private static void stackTrace()
{
StringWriter sw = new StringWriter();

PrintWriter pw = new PrintWriter(sw);

new Throwable().printStackTrace(pw);

System.out.println(sw.toString());

}

public static void main(String[] args) {

stackTrace();

}

} // StackTrace

Output -

java.lang.Throwable
at StackTrace.stackTrace(StackTrace.java:18)
at StackTrace.main(StackTrace.java:23)


instead of System.out.println you could use the setText method of JTextArea.
About | Sitemap | Contact