When I pass in: "*" 3 5 I expect "*" to be stored in argv[0], 3 in argv[1], and 5 in argv[2]
But instead, it will store .classpath, .project, .settings, bin, src, 3, 5 making argv.length == 7 instead of 3.
I know the problem is occurring at argument input. I can solve this by having the user format the argument input but that will not suffice as the format for the input is an asterisk in double quotes. I am able to pass in an asterisk in single quotes, but the problem is when it is passed in with double quotes (using Eclipse >> run configurations >> arguments >> "*" 3 3) "*" will pass in a directory instead of the string asterisk in double quotes.
How do I get asterisk in double quotes to be read in as a string? I know it can be done, I'm just trying to figure out why it is being read in as a directory. Following any other example, double quotes should resolve the problem but not so in this case.
/**
* Drives the program.
* @param argv arguments from command line
*/
public static void main(final String[] argv) {
final TableType type;
final int start;
final int stop;
for(int i=0; i<argv.length; i++){
System.out.println(argv[i]);
}
if (argv.length != 3) {
usage();
}
System.out.println(argv[0]);
type = getType(argv[0]);
start = getNumber(argv[1]);
stop = getNumber(argv[2]);
displayTable(type, start, stop);
}
/**
* Returns the TableType represented by the specified String.
* @param str the table type
* @return TableType
*/
public static TableType getType(final String str) {
final TableType type;
if (str.equals("+")) {
type = TableType.ADD;
} else if (str.equals("\"*\"")) {
type = TableType.MULT;
} else {
usage();
type = null;
}
return (type);
}