File Redirection (optional)

Sometimes it makes more sense to take your input from a file rather than direct keyboard input. This is known as input redirection.

Instead of running your program and entering your input when the program prompts you for it, you can put your input into a file and run your program in the following manner:

Make a file called input.txt with your inputs separated by newline characters.

Now run the following command in the terminal from your bin directory:

java lab2.ScannerInput < input.txt

Your output should be the same as it was earlier in the lab.

You may also redirect your output to a file by using redirection.

Now run the following command in the terminal and examine the contents of the output.txt file:

java lab2.ScannerInput < input.txt > output.txt