java test >myfile
Same thing can be achieved by using PrintWriter cleverly.
System class has methods to let you set your own PrintWriter to it. - System.setOut()
As a point of interest, the JDK 1.3 implementation of java.lang.System
has internal code of this form:
FileOutputStream fdOut =
new FileOutputStream(FileDescriptor.out);
setOut0(new PrintStream(
new BufferedOutputStream(fdOut, 128), true));
Check out this TechTips for more info about IO Redirection and Array Manipulation.