I'm trying to run a main method that requires four arguments, but the last one can be null (If #4 is null, use the string value in #2 as input. If #4 is NOT null, use #4 as a file path and use the string in that file as input instead. Bad coding, I didn't write it). However, I'm having trouble getting Eclipse to accept that fourth argument as null.
If I put anything on the fourth line, it takes it as a string. If I put nothing, then it only processes three arguments.
Does anyone know how to get it to accept a null value through the run configuration arguments?
Thanks in advance,
Brandon
The arguments can never be null. They just won't exist, so what you need to do is to check the length of your arguments.
public static void main(String[] args)
{
// Check how many arguments were passed in
if(args.length == 3)
{
//the last arguement is null
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With