Setting and resetting stdout

Hi,

I'd like to temporarily redirect IO fron within java code. The redirecting part is easy enough using System.setOut(printStream) but the lack of a corresponding System.getOut( ) is keeping me from restoring the old value. In other words, I want to do this:

PrintStream newOut = ...

PrintStream oldOut = System.getOut( );

System.setOut(newOut);

// Write a bunch of stuff to the new stdout

// Restore the old value

System.setOut(oldOut);

but of course, can't, becasue there is no System.getOut( ). I'm sure there is a simple solutin here, but I'm not seeing it. Can anyone point me in the right direction? Thanks in advance.

-exits

[697 byte] By [ExitsFunnela] at [2007-11-27 11:20:28]
# 1

Lookk at the API documentation for the System class - see the Field Summary information?

It tells you what the default (standard) output, input, and error streams' names are. Unless you had previously set the standard output to something else, then you would return it to System.out. If you had previously set it to something else, then you need to save that information so that it can be retrieved when you want to restore standard out.

ChuckBinga at 2007-7-29 14:42:53 > top of Java-index,Core,Core APIs...