go to previous page   go to home page   go to next page

Answer:

The old contents of stuff.txt are entirely replaced with the new output.


Printing a Program's Output

One way to send the output of a program to a printer is to redirect its output to a text file (as in the previous page), then read the file into Notepad or other editor, then use the editor's print command.

Here is a Hello.java program that can be copied to a source file and run to practice redirection.


class Hello
{
  public static void main ( String[] args )
  {
    System.out.println("Hello World");
  }
}

Here is that program being used with output redirection:

C:\temp>javac Hello.java

C:\temp>java Hello > output.txt

C:\temp>type output.txt
Hello World

C:\temp>


QUESTION 10:

After the above commands have been executed, what happens to the file called output.txt in the subdirectory C:\Myfiles ?