Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.out.println output to JTextArea

I would like to everytime I call System.out.println to append to a given JTextArea, without having to change all calls to System.out.println... Is this possible?

Thank you.

like image 406
Pedro Avatar asked Dec 08 '25 10:12

Pedro


2 Answers

Versions of Java since 1.5 have System.setOut() which allow you to install your own PrintStream. Just create a simple OutputStream which appends the data it get through write() Then wrap it in a PrintStream and install it.

like image 132
Aaron Digulla Avatar answered Dec 10 '25 01:12

Aaron Digulla


Well You can do it using the jTextArea.append("Your String") method

like image 25
Ramindu Samarawickrama Avatar answered Dec 10 '25 01:12

Ramindu Samarawickrama