Monday, February 21, 2011

shlex alternative for Java

Is there a shlex alternative for Java? I'd like to be able to split quote delimited strings like the shell would process them. For example, if I'd send :

one two "three four"
and perform a split, I'd like to receive the tokens
one
two
three four

From stackoverflow
  • Look at Apache Commons Lang:

    org.apache.commons.lang.text.StrTokenizer should be able to do what you want:

    new StringTokenizer("one two \"three four\"", ' ', '"').getTokenArray();
    

0 comments:

Post a Comment