What's the recommended way to parse a shell-like command line in Java. By that I don't mean processing the options when they are already in array form (e.g. handling "-x" and such), there are loads of questions and answers about that already.
No, I mean the splitting of a full command string into "tokens". I need to convert a string such as:
user 123712378 suspend "They are \"bad guys\"" Or\ are\ they?
...to the list/array:
user
123712378
suspend
They are "bad guys"
Or are they?
I'm currently just doing a split on whitespace, but that obviously can't handle the quotes and escaped spaces.
(Quote handling is most important. Escaped spaces would be nice-to-have)
Note: My command string is the input from a shell-like web interface. It's not built from main(String[] args)