Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to handle a NULL args[] value

 
bob connolly
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

When passing in a long string of args[] values, if the DBO value is NULL, it shifts the whole lineup of args[] values in by 1 position!

Is there a better way to handle NULL args[] values or is there a better way to pass a large list of args[] values into a Java program?

Thanks much!
bc

 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can quote the arguments so they show up as empty strings when they have no value.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do a check at the beginning of the app to verify that you have the correct number of args passed in.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If some arguments are optional, you can use a flag (like -d) to indicate that the next argument is the optional argument.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic