I need to parse my main method to see if the boolean is set to true or false, but every time i run it it is being set to false.
when I go to run the program, this is my interactions output:
> java ScraperTestRunner1 true, "/Desktop/imputfile.txt"
2
false
/Desktop/imputfile.txt
my code for this main method is:
public static void main(String[] args){
System.out.println(args.length);
if (args.length == 2) {
docketBoolean = Boolean.parseBoolean(args[0]);
inputDateFileString = (args[1]);
System.out.println(docketBoolean);
System.out.println(inputDateFileString);
Before when i checked to see if args.length was 1, then only searched for the boolean it would give me the correct boolean, but now it is not. Any idea why this may be?
You're parsing "true,"
which is not the same as "true"
.
Get rid of the comma in your invocation:
java ScraperTestRunner1 true "/Desktop/imputfile.txt"
Command line arguments aren't specified as a comma-separated list; they're space-separated (with double quotes to allow spaces within an argument).
See more on this question at Stackoverflow