Java Reference
In-Depth Information
ch07/regression/input1.txt
15000
2
1015
10000
The command line interfaces of most operating systems provide a way to link a file to
the input of a program, as if all the characters in the file had actually been typed by a
user. Type the following command into a shell window:
java BankTester < input1.txt
The program is executed, but it no longer reads input from the keyboard. Instead, the
System.in
object (and the
Scanner
that reads from
System.in
) gets the input
from the file
input1.txt
. This process is called input redirection.
The output is still displayed in the console window:
Output
Count: 2
Expected: 2
Balance of matching account: 10000
Expected: 10000
320
321
You can also redirect output. To capture the output of a program in a file, use the
command
java BankTester < input1.txt > output1.txt
This is useful for archiving test cases.
S
ELF
C
HECK
15.
Suppose you modified the code for a method. Why do you want to
repeat tests that already passed with the previous version of the code?
16.
Suppose a customer of your program finds an error. What action should
you take beyond fixing the error?