I'm trying to write a Java wrapper which will internally call a shell script passing the required arguments to the script. My class would be called as follows:
MyClass --arg1 value1 --arg2 value2 --arg3 value3
I would like to know what is the best way to parse these arguments? My current approach is as follows:
- Split the space separated arguments and store them in an array
- Go through the array and check for --argX and then pick the next element as the value for that argument.
However, my current approach seems menial to me and I'm looking for better ways of doing this.
\\winstead of\w. Happy coding !