In Java, I have redirected System.out
: System.setOut("someText.txt");
to write to a text file. I would like to run this program once an hour, and would like to append each set of print statements to the end of the file. For example suppose at hour 1, my program runs, prints "Hello\n" and then quits. Then at hour 2, my program runs, prints "hello again\n", and then quits.
If this happened I would like the contents of my text-file to be something like:
Hello
Hello again
Currently, I am just overwriting the text file.
- How can I append to the end of the text file with this redirected printStream?
EDIT How can I also print to the console?