In Windows:
you can copy to the system clipboard your program's output from it's console window, and then paste it to a text file opened in a text editor, or
you can run your program like this:
c:\>java yourclass >out.txt, or
you can modify your code to make the program output to the text file. Here is a piece of code as an example:
[ July 20, 2004: Message edited by: Dmitry Melnik ]
[ July 20, 2004: Message edited by: Dmitry Melnik ]