commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Tripp" <>
Subject [cli] method to convert a string (which is a whole command line) into an array (of arguments)
Date Wed, 02 Apr 2008 19:58:24 GMT
Hello.  I've been looking for a method to parse a command-line string into
an string-array (for use with commons CLI, Runtime.exec(), etc.)  I haven't
been able to find one in commons CLI.  So my questions are:

a)	Is there a method in the commons (CLI or elsewhere) that does this,
that I have missed?
b)	If not, might such a method be a welcome addition to the commons?
(because after much searching, I found one in the Eclipse source code.)

This need arises from a part of my application where the user can enter a
command line into a GUI text field, which needs to be able to handle
arguments with spaces (via quotes), escaped quotes, etc.  I ended up using
some code lifted from Eclipse, which corresponds to what happens to the
strings entered in the Run dialog > Java application > Arguments tab before
a process is launched (since, obviously, the user-entered command-line
string needs to be converted into a string-array somehow.)  

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message