The stream redirection demo application shows the various steps you can take to redirect all three of the standard streams to or from regular files using Java 1.1.
The java.lang.System API was changed in Java 1.1 such that the in, out, and err streams are now final. Luckily, the API was also extended to include methods to change those streams: setIn(), setOut(), and setErr(), respectively.
As before, the application presumes that a file called Redirect.in exists. It reads that file in place of the System.in standard input stream and prints it to the original System.out standard output stream. The application will redirect the System.out output stream and the System.err standard error stream to the Redirect.out and Redirect.err files, respectively.
Note that you will get warnings when compiling Redirect.java. These warnings are generated in Java 1.1 since the use of the PrintStream constructors have been deprecated. PrintStream has mostly been superseded by the PrintWriter class, but PrintStream is still used for the System.in and System.out streams. So, just ignore those deprecation warnings for this particular use
of PrintStream.
Thanks to Jeff Rhyason for prompting us for this update.
Thanks?By Heliski on November 5, 2009, 11:45 amThanks for what? Heliskiing | Heliski
Reply | Read entire comment
Thanks!By free games on September 27, 2009, 2:09 amThanks!
Reply | Read entire comment
Problem is redirecting error streamBy Lee on June 15, 2009, 1:07 amsorry for the above incomplete comment. Actually I'm facing one problem. 1. I'm running one java program inside from other java program 2. This I'm achieving...
Reply | Read entire comment
Problem is redirecting error streamBy Anonymous on June 15, 2009, 1:04 amsorry for the above incomplete comment. Actually I'm facing one problem. 1. I'm running one java program inside from other java program 2. This I'm achieving by ...
Reply | Read entire comment
Problem is redirecting error streamBy Anonymous on June 15, 2009, 12:59 amA
Reply | Read entire comment
View all comments