I have implemented a program that invokes some Linux commands to complete a number of tasks. My problem is that I want to add a GUI to the application, so I need to somehow redirect the output of the commands from the error and the out streams to a graphical components, such as a JTextArea.... However, I am not sure how to do it. The code I currently have looks like this:
It would be great if it was the stderr and stdout of the current application that should be great. In this case, it's the stderr and stdout from a separate process.
Konstantinos, first of all, please read this. You'll find it very useful.
In that article, the StreamGobbler code on page 4 is almost what you want. However, instead of printing, you want to add it:
Apart from appending only the exception's String form, you can print the stack trace to the text area as well, using my patented ( ) TextAreaWriter: