The old contents of stuff.txt
are entirely replaced with the new output.
You can redirect the output of a program to a text file then read the file into Notepad or other editor, and use the editor's print command.
Here is a Hello.java
program.
Copy and run it to practice
redirection.
public 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>
After the above commands have been executed,
what happens to the file called output.txt
in
the subdirectory C:\MyFiles
?