when compiling a java program you normally use java programName
.
What does the below line mean?
java BinarySearch whitelist.txt < input.txt
What are the 2 txt files doing (is it input output files) what is the < mean
Thanks
when compiling a java program you normally use java programName
.
What does the below line mean?
java BinarySearch whitelist.txt < input.txt
What are the 2 txt files doing (is it input output files) what is the < mean
Thanks
In this case, the <
character will redirect the standard input to the input.txt
file. This means that System.in
will represent the file, rather than the console input. Using the >
character would instead redirect the standard output to the file, so that System.out
will represent the file, rather than the console output. These characters are not interpreted by the java virtual machine, but by the shell.
Since there is no special character in front of whitelist.txt
, it just acts as an argument to the java program, and will be stored in args[0]
(or whatever the arguments variable is named in the program).
By the way, using the java program
command will not compile the java file, it will instead run the compiled class file. To compile a java file, use the javac file.java
command.
The args* following **BinarySearch are inputs into the program.
As shown in the documentation for the code, <
is being used for redirect from StdIn.