Redirecting java console output

well as usual I did not find the right section to put this, but oh well

I would like to see the java console output in my game.
I tried System.console() (java.io.console) but im not quite sure if its even designed to do this.
there is console.readline() but its always null

motives:
obviously you cannot try and catch everything, therefore, bugs cause errors and these exceptions are shown in the java console
now since my game is in fullscreen, or rather especially because of this reason not only, i would like to draw the console on the screen while the game is running
seems pretty usual in c++ game development.
especially useful if a exception happens but it doesnt crashes the game, you can see exactly when it happens.

any ideas / experiences ?

EDIT: of course I have my own gameConsole, but like I said you cannot try and catch everything, and I want to copy exception or even redirect to my gameConsole, so that I can see them in my game

this one :
http://java.sun.com/j2se/1.3/docs/api/java/lang/System.html#setOut(java.io.PrintStream) (setOut method)

hm it wants a PrintStream. I can create a PrintStream, but do I get the Lines, as String from it ?
im really not good with streams in general =D

ah nevermind ByteArrayOutputStream.toString() actually works

For educational purposes(newbs like me) here the complete code:


String constr[]; // this is our console as strings
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
PrintStream ps = new PrintStream( outstream );
...
System.setOut( ps ); // you may wanna do this as soon as your graphical console is somehow available
System.setErr( ps );  // whatever you wanna output of course
...

constr = outstream.toString().split("\n"); // you get the lines

// and now constr[0] is the first line and so on and so on
// but of course you have to update the strings


Ideally you would avoid using System.out entirely; use the stuff in the java.util.logger package instead. (then you can create a logger implementation to redirect it to whatever user interface your game has)