System.out.println output to JTextArea

console, java, jtextarea

Solution

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.

Problem

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.

Original source